Skip to content

Apply some Pylint fixes#1448

Draft
EmilyBourne wants to merge 123 commits intodevelfrom
ebourne_codacy
Draft

Apply some Pylint fixes#1448
EmilyBourne wants to merge 123 commits intodevelfrom
ebourne_codacy

Conversation

@EmilyBourne
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
Member Author

/bot run docs

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 18, 2023

Ran tests on commit ce1186d, for more details see here

  • ❌ docs / Documentation Format

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run docs

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 18, 2023

Ran tests on commit a3ea161, for more details see here

  • ❌ docs / Documentation Format

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run docs

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run docs

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run linux

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run linux docs

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run linux docs

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run linux docs

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run linux docs

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run coverage pylint pyccel_lint docs

Copy link
Copy Markdown

@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.

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
Copy Markdown

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

Comment thread pyccel/codegen/printing/ccode.py Outdated
Comment thread pyccel/codegen/printing/ccode.py Outdated
Comment thread pyccel/codegen/printing/ccode.py Outdated
args = [self._print(a) for a in expr.args]
if len(args) == 1:
return '-{}'.format(args[0])
return '-{args[0]}'
Copy link
Copy Markdown

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

Comment thread pyccel/codegen/printing/fcode.py
fs = ', '.join(i for i in args)

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

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
Copy Markdown

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This seems to be fixed now! Thank you for looking into this. Please resolve this conversation.

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

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

if lib.endswith('.dylib'):
end = end-5
return '-l{}'.format(lib[3:end])
return '-l'+lib[3:end]
Copy link
Copy Markdown

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

Copy link
Copy Markdown

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
@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run coverage

Copy link
Copy Markdown

@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.

Comment on lines +667 to 668
line = f'{prefix} {target}'

Copy link
Copy Markdown

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

Comment on lines +982 to 983
return f'"{expr.variables} -> {expr.expr}"'

Copy link
Copy Markdown

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This seems to be fixed now! Thank you for looking into this. Please resolve this conversation.

Comment thread pyccel/codegen/printing/fcode.py Outdated
Comment on lines 1527 to 1528
dtype += f'({self.print_kind(expr.variable)})'

Copy link
Copy Markdown

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This seems to be fixed now! Thank you for looking into this. Please resolve this conversation.

Comment thread pyccel/codegen/printing/fcode.py Outdated
Comment on lines 1718 to 1719
rhs_code = f'{lhs_code} % {rhs_code}'

Copy link
Copy Markdown

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

Comment on lines +2263 to 2264
return ''.join((prolog, loop, epilog))

Copy link
Copy Markdown

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

Comment thread pyccel/codegen/printing/fcode.py Outdated
Comment on lines 2594 to 2597
arg1 = self._print(expr.args[0])
arg2 = self._print(expr.args[1])
return f'LSHIFT({arg1}, {arg2})'

Copy link
Copy Markdown

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This seems to be fixed now! Thank you for looking into this. Please resolve this conversation.

Comment on lines +2767 to 2768
return f'transpose({arg})'
else:
Copy link
Copy Markdown

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

Comment on lines +473 to 477
start = self._print(expr.start)
stop = self._print(expr.stop )
step = self._print(expr.step )
return f'range({start}, {stop}, {step})'

Copy link
Copy Markdown

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

Comment thread pyccel/codegen/printing/pycode.py Outdated
Comment on lines +1077 to 1080
lhs = self._print(expr.args[0])
rhs = self._print(expr.args[1])
return f'{lhs} << {rhs}'

Copy link
Copy Markdown

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
Copy link
Copy Markdown
Member Author

/bot run coverage

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run linux

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run coverage

Copy link
Copy Markdown

@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.

raise NotImplementedError(' tuple with elements of rank > 0 is not implemented')
fs = ', '.join(self._print(f) for f in expr)
return '[{0}]'.format(fs)
return f'[{fs}]'
Copy link
Copy Markdown

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_InhomogeneousTupleVariable(self, expr):
fs = ', '.join(self._print(f) for f in expr)
return '[{0}]'.format(fs)
return f'[{fs}]'
Copy link
Copy Markdown

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

Comment on lines +2057 to 2059
rhs_code = f'-Huge({lhs_code})'
return f'{lhs_code} = {rhs_code}\n'

Copy link
Copy Markdown

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

Comment on lines +2061 to +2062
rhs_code = f'Huge({lhs_code})'
return f'{lhs_code} = {rhs_code}\n'
Copy link
Copy Markdown

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

return f'{name}({self._print(expr.internal_var)})'
else:
return '{}({}+{}*1j)'.format(name, self._print(expr.real), self._print(expr.imag))
return f'{name}({self._print(expr.real)}+{self._print(expr.imag)}*1j)'
Copy link
Copy Markdown

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

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.

1 participant