-
Notifications
You must be signed in to change notification settings - Fork 191
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
🔧 MAINTAIN: Update pylint version (& fix new issues) #5087
Conversation
Update pylint to v2.9 and remove restrictions on astroid and pylint-django. - `django-not-available` -> `django-not-configured` - Fix new `consider-using-dict-items`, `consider-using-enumerate`, `too-many-function-args`, `consider-using-from-import`, `consider-using-max-builtin`, `arguments-renamed` - extra disables required for `no-member` - disable `unsubscriptable-object` for cif.vaues closes aiidateam#4647
Also I removed there was some issues in pylint about this, but they claimed to be closed with the latest pylint (i.e. this one) |
Codecov Report
@@ Coverage Diff @@
## develop #5087 +/- ##
===========================================
+ Coverage 80.50% 80.52% +0.03%
===========================================
Files 531 531
Lines 37020 37095 +75
===========================================
+ Hits 29799 29867 +68
- Misses 7221 7228 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
there's 100s of |
Intend to merge this in the next day, as it will affect all other PRs |
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.
Have a couple of questions about certain disables. Initially repeated them at each line that I though they applied, but stopped after a while because there are so many instances. If you agree that in certain places we should actually fix instead of disabling, please have a look at other instances as well
@@ -254,6 +254,7 @@ def migrate(input_file, output_file, force, in_place, archive_format, version, v | |||
|
|||
class ExtrasImportCode(Enum): | |||
"""Exit codes for the verdi command line.""" | |||
# pylint: disable=invalid-name |
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.
Won't this now disable this for the entire file? Or is it properly scoped to the enum
?
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.
yeh, I was hoping it would be scoped to the enum
, or do you think not?
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.
Not sure to be honest. You could give it a quick try by adding a global constant after the enum declaration which should then incur a warning from pylint if it is properly scoped.
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.
Yep looks to work as intended, FYI scoping is detailed here: http://pylint.pycqa.org/en/latest/user_guide/message-control.html#block-disables
@@ -158,7 +158,7 @@ def logshow(): | |||
|
|||
try: | |||
currenv = get_env_with_venv_bin() | |||
process = subprocess.Popen(['tail', '-f', client.daemon_log_file], env=currenv) | |||
process = subprocess.Popen(['tail', '-f', client.daemon_log_file], env=currenv) # pylint: disable=consider-using-with |
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.
Instead of disabling, couldn't we actually not better use a with statement here?
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.
It wasn't quickly apparent to me how to do this and keep the same behaviour. i.e. is the same?
currenv = get_env_with_venv_bin()
with subprocess.Popen(['tail', '-f', client.daemon_log_file], env=currenv) as process:
try:
process.wait()
except KeyboardInterrupt:
process.kill()
probably not 🤷
same with the other disable=consider-using-with
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.
Fair enough. I would be tempted to do:
currenv = get_env_with_venv_bin()
try:
with subprocess.Popen(['tail', '-f', client.daemon_log_file], env=currenv) as process:
process.wait()
except KeyboardInterrupt:
process.kill()
But I am not sure the try-except is even necessary when using the context manager. Keyboard interrupt should just kill it and the context manager should clean it up properly. Anyway, indeed fine to keep this as is as it is not a trivial change
@@ -220,7 +220,7 @@ def _show_xmgrace(exec_name, list_bands): | |||
'agr', setnumber_offset=current_band_number, color_number=(iband + 1 % MAX_NUM_AGR_COLORS) | |||
) | |||
# write a tempfile | |||
tempf = tempfile.NamedTemporaryFile('w+b', suffix='.agr') | |||
tempf = tempfile.NamedTemporaryFile('w+b', suffix='.agr') # pylint: disable=consider-using-with |
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.
Idem: Instead of disabling, couldn't we actually not better use a with statement here?
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.
as above, what code would you propose? (just a more complex code changes then I was willing to make, when going through the 100s of issue fixes 😅)
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.
I see now. Didn't notice it was creating a list of handles and then processing them. What the hell 🤦♂️ OK, fine to leave this as is for now
@@ -114,7 +114,7 @@ def run(scriptname, varargs, auto_group, auto_group_label_prefix, exclude, inclu | |||
|
|||
try: | |||
# Here we use a standard open and not open, as exec will later fail if passed a unicode type string. | |||
handle = open(scriptname, 'r') | |||
handle = open(scriptname, 'r') # pylint: disable=consider-using-with |
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.
Idem: instead of disabling, couldn't we actually not better use a with statement here?
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.
as above; basically I would maybe open a separate issue to address seom of the disable=consider-using-with
, because some of them feel like they need a bit of scrutiny to double check they won't break the current behaviour
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.
Good idea to open an issue and leave all of these with disable statements for now
addressed your comments thanks @sphuber |
aiida/schedulers/plugins/lsf.py
Outdated
@classmethod | ||
def validate_resources(cls, **kwargs): | ||
"""Validate the resources against the job resource class of this scheduler. | ||
|
||
:param kwargs: dictionary of values to define the job resources | ||
:return: attribute dictionary with the parsed parameters populated | ||
:raises ValueError: if the resources are invalid or incomplete | ||
""" | ||
|
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.
Guessing @abstractclassmethod
didn't actually work, since this was not picked up before? @sphuber I guess this should probably have some content
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.
Yeah that is weird indeed. I guess the validation is already done in the constructor. We can just move that logic to the validate_resources
. To be safe as to not break anything, you can always still call self.validate_resources(**kwargs)
from the constructor, which is what the NodeNumberJobResource
also does.
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.
done
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.
Thanks @chrisjsewell . Would be good if you can still check the comment on the Enum and the scheduler job resource validation, but am already approving this
for more information, see https://pre-commit.ci
all done cheers |
Update pylint pinning to v2.9 and remove restrictions on astroid and pylint-django.
django-not-available
->django-not-configured
consider-using-dict-items
,consider-using-enumerate
,too-many-function-args
,consider-using-from-import
,consider-using-max-builtin
,arguments-renamed
,consider-using-with
,use-maxsplit-arg
,use-a-generator
,deprecated-decorator
no-member
(pylint seems to be getting worse at identifying members, or at least more strict)unsubscriptable-object
forcif.values
closes #4647