Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply some Pylint fixes #1448

Draft
wants to merge 117 commits into
base: devel
Choose a base branch
from
Draft

Apply some Pylint fixes #1448

wants to merge 117 commits into from

Conversation

EmilyBourne
Copy link
Member

@EmilyBourne EmilyBourne commented Jul 18, 2023

This PR is probably too large. I am gradually breaking it into manageable chunks that are merged in individual PRs.

Fix a variety of pylint errors across the code base; notably the errors:

  • Unused-import
  • Consider-using-f-string

Additionally tidy the code somewhat by:

  • Add docstrings
  • Remove unnecessary function CodePrinter._get_statement and unused function CodePrinter._get_comment

@github-actions
Copy link

github-actions bot commented Jul 18, 2023

Hello again! Thank you for this new pull request 🤩.

Don't forget to let me know when it is complete with the command /bot mark as ready.

Here is your checklist:

  • Write a clear PR description
  • Add tests to check your code works as expected
  • Update documentation if necessary
  • Update Changelog
  • Ensure any relevant issues are linked
  • Ensure new tests are passing

@EmilyBourne
Copy link
Member Author

/bot run docs

@github-actions
Copy link

github-actions bot commented Jul 18, 2023

Ran tests on commit ce1186d, for more details see here

  • ❌ docs / Documentation Format

@EmilyBourne
Copy link
Member Author

/bot run docs

@github-actions
Copy link

github-actions bot commented Jul 18, 2023

Ran tests on commit a3ea161, for more details see here

  • ❌ docs / Documentation Format

@EmilyBourne
Copy link
Member Author

/bot run docs

@EmilyBourne
Copy link
Member Author

/bot run docs

@EmilyBourne
Copy link
Member Author

/bot run linux

@EmilyBourne
Copy link
Member Author

/bot run linux docs

@EmilyBourne
Copy link
Member Author

/bot run linux docs

@EmilyBourne
Copy link
Member Author

/bot run linux docs

@EmilyBourne
Copy link
Member Author

/bot run linux docs

@EmilyBourne
Copy link
Member Author

/bot run linux

@EmilyBourne
Copy link
Member Author

/bot run coverage pylint pyccel_lint docs

@EmilyBourne
Copy link
Member Author

/bot run coverage pylint pyccel_lint docs

Copy link

@pyccel-bot pyccel-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be lines in this PR which aren't tested. Please take a look at my comments and add tests which cover the new code.

If this is modified code which cannot be easily tested in this PR please open an issue to request that this code be either removed or tested. Once you have done that please leave a message on the relevant conversation beginning with the line /bot accept and referencing the issue.

Similarly if the new code cannot be tested for some reason, please leave a comment beginning with the line /bot accept on the relevant conversation explaining why the code can't be tested.

@@ -1046,7 +1037,7 @@ def _print_PythonPrint(self, expr):
for f in kwargs:
if f.keyword == 'sep' : sep = str(f.value)
elif f.keyword == 'end' : end = str(f.value)
else: errors.report("{} not implemented as a keyworded argument".format(f.keyword), severity='fatal')
else: errors.report(f"{f.keyword} not implemented as a keyworded argument", severity='fatal')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't tested. Please can you take a look

@@ -1265,7 +1256,7 @@
arg_code = 'void'
else:
# TODO: extract informations needed for printing in case of function argument which itself has a function argument
arg_code = ', '.join('{}'.format(self._print_FuncAddressDeclare(i))
arg_code = ', '.join(self._print_FuncAddressDeclare(i)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't tested. Please can you take a look

@@ -1505,14 +1496,15 @@
def _print_PyccelArraySize(self, expr):
arg = expr.arg
if self.is_c_pointer(arg):
return '{}->length'.format(self._print(ObjectAddress(arg)))
return '{}.length'.format(self._print(arg))
return f'{self._print(ObjectAddress(arg))}->length'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't tested. Please can you take a look

@@ -2033,7 +2023,7 @@
def _print_PyccelMinus(self, expr):
args = [self._print(a) for a in expr.args]
if len(args) == 1:
return '-{}'.format(args[0])
return '-{args[0]}'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't tested. Please can you take a look


elif isinstance(new_name, DottedName):
target = '_'.join(self._print(j) for j in new_name.name)
line = '{prefix} {target}'.format(prefix=prefix,
target=target)
line = f'{prefix} {target}'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't tested. Please can you take a look

@@ -947,7 +931,7 @@

fs = ', '.join(i for i in args)

return 'print({0})\n'.format(fs)
return f'print({fs})\n'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't tested. Please can you take a look


def _print_PyccelLShift(self, expr):
return '{} << {}'.format(self._print(expr.args[0]), self._print(expr.args[1]))
lhs = self._print(expr.args[0])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't tested. Please can you take a look

message : str
The message reported by the parser.
"""
sys.stderr.write(f'error: {message}\n')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't tested. Please can you take a look

@@ -214,7 +214,7 @@ def change_to_lib_flag(lib):
end = end-3
if lib.endswith('.dylib'):
end = end-5
return '-l{}'.format(lib[3:end])
return '-l'+lib[3:end]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't tested. Please can you take a look

@@ -98,5 +98,5 @@
name = 'private'+name
name = self._get_collisionless_name(name, symbols)
if len(name) > 96:
warnings.warn("Name {} is too long for Fortran. This may cause compiler errors".format(name))
warnings.warn(f"Name {name} is too long for Fortran. This may cause compiler errors")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't tested. Please can you take a look

@EmilyBourne EmilyBourne self-assigned this May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant