Skip to content

Commit

Permalink
Linting fixes!
Browse files Browse the repository at this point in the history
  • Loading branch information
LonelyCat124 committed Jan 30, 2025
1 parent 438c135 commit 04dddaf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/psyclone/psyir/transformations/loop_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def apply(self, node, options=None, node_type_check: bool = True,
:param node_type_check: If the type of nodes enclosed in the loop
should be tested to avoid including
unsupported nodes in the transformation.
:param verbose: whether to log the reason the validation failed, at
:param verbose: whether to log the reason the validation failed, at
the moment with a comment in the provided PSyIR node.
'''
super().apply(node, options=options, node_type_check=node_type_check,
Expand Down
1 change: 1 addition & 0 deletions src/psyclone/psyir/transformations/parallel_loop_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

from psyclone.utils import transformation_documentation_wrapper


@transformation_documentation_wrapper
class ParallelLoopTrans(LoopTrans, metaclass=abc.ABCMeta):
'''
Expand Down
23 changes: 12 additions & 11 deletions src/psyclone/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

import sys
import re
from psyclone.errors import InternalError


def within_virtual_env():
Expand Down Expand Up @@ -69,6 +70,7 @@ def a_or_an(string):
return "an"
return "a"


def transformation_documentation_wrapper(cls, *args, inherit=True, **kwargs):
def get_inherited_parameters(cls):
docs = cls.apply.__doc__
Expand All @@ -79,15 +81,15 @@ def get_inherited_parameters(cls):
parent_lines = []

Check warning on line 81 in src/psyclone/utils.py

View check run for this annotation

Codecov / codecov/patch

src/psyclone/utils.py#L81

Added line #L81 was not covered by tests
added_docs = ""
for x, line in enumerate(parent_lines):
if(":param" in line):
if ":param" in line:
param_str = re.search(":[a-zA-Z0-9\\s]*:", line)
if( param_str is None or param_str.group() in docs):
if param_str is None or param_str.group() in docs:
continue
added_docs += "\n" + line
z = x+1
type_found = False
while(z < len(parent_lines)):
if(":param" in parent_lines[z]
while z < len(parent_lines):
if (":param" in parent_lines[z]
or ":raises" in parent_lines[z]):
# If we didn't find the :type: docstring,
# we need to create it to inherit the docstring
Expand Down Expand Up @@ -115,11 +117,11 @@ def get_inherited_parameters(cls):
f"for class '{cls.__name__}' as the "
f"'{param_name}' arg has no known type."
)
type_doc = f" "
type_doc = " "
type_doc += f":type {param_name}: {type_string}"
added_docs += "\n"+ type_doc
added_docs += "\n" + type_doc
break

Check warning on line 123 in src/psyclone/utils.py

View check run for this annotation

Codecov / codecov/patch

src/psyclone/utils.py#L120-L123

Added lines #L120 - L123 were not covered by tests
if(":type" in parent_lines[z]):
if ":type" in parent_lines[z]:
type_found = True

Check warning on line 125 in src/psyclone/utils.py

View check run for this annotation

Codecov / codecov/patch

src/psyclone/utils.py#L125

Added line #L125 was not covered by tests
if not parent_lines[z].isspace():
added_docs += "\n" + parent_lines[z]
Expand Down Expand Up @@ -148,9 +150,9 @@ def get_inherited_parameters(cls):
f"for class '{cls.__name__}' as the "
f"'{param_name}' arg has no known type."
)
type_doc = f" "
type_doc = " "
type_doc += f":type {param_name}: {type_string}"
added_docs += "\n"+ type_doc
added_docs += "\n" + type_doc
return added_docs

def update_apply(cls, added_parameters):
Expand All @@ -161,7 +163,7 @@ def update_apply(cls, added_parameters):
if ":param" in line or ":type" in line:
last_instance = i
x = i+1
while(x < len(doc_lines)):
while x < len(doc_lines):
if not (":param" in line or ":type" in line or
":raise" in line):
# This is part of the previous section.
Expand All @@ -179,7 +181,6 @@ def update_apply(cls, added_parameters):
new_docs += doc_lines[i] + "\n"

cls.apply.__doc__ = new_docs


def wrapper():
if inherit:
Expand Down

0 comments on commit 04dddaf

Please sign in to comment.