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
base: devel
Are you sure you want to change the base?
Apply some Pylint fixes #1448
Conversation
Hello again! Thank you for this new pull request 🤩. Don't forget to let me know when it is complete with the command Here is your checklist:
|
/bot run docs |
/bot run docs |
/bot run docs |
/bot run docs |
/bot run linux |
/bot run linux docs |
ef51a7c
to
e5b9870
Compare
/bot run linux docs |
/bot run linux docs |
/bot run linux docs |
/bot run linux |
/bot run coverage pylint pyccel_lint docs |
/bot run coverage pylint pyccel_lint docs |
There was a problem hiding this 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') |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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]}' |
There was a problem hiding this comment.
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}' |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
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:
Additionally tidy the code somewhat by:
CodePrinter._get_statement
and unused functionCodePrinter._get_comment