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
Refactor --list-msgs
& --list-msgs-enabled
#4793
Conversation
Both options now show which messages can't be emitted with the current interpreter. This makes function more like their name implies. This closes pylint-dev#4778
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.
Nice job ! Could we refactor a little further and create a common function to recover emitable/non-emittable ? This way list_messages_enabled
would loop on the result of this function and the other one would use them directly.
pylint/lint/pylinter.py
Outdated
enabled = [] | ||
disabled = [] | ||
non_emittable = [] | ||
for message in self.msgs_store.messages: |
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.
Nice refactor 👍
Where should I put this common function? Is there a good place for utils function for files in different directories? Thinking of: def find_emittable_messages(
messages: List[MessageDefinition],
) -> Tuple[List[MessageDefinition], List[ValuesView[MessageDefinition]]]:
emittable = []
non_emittable = []
for message in messages:
if message.may_be_emitted():
emittable.append(message)
else:
non_emittable.append(message)
return emittable, non_emittable |
|
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.
Thank you !
FYI, my recent pylint bash completion PR at scop/bash-completion#562 is what triggered to me to file #4778. Looking at the code here it seems my scraper would be still doing the right thing after these changes, cool. The scraper is far from pretty, but all things considered I don't think we have a better choice at the moment, and if we want to support old pylint versions out there, new additions of e.g. better machine parseable outputs for these in new releases wouldn't help either. |
doc/whatsnew/<current release.rst>
.Type of Changes
Description
Both options now show which messages can't be emitted with the current interpreter. This makes function more like their name implies. Code clearly shows in which order/format the messages are emitted.
This closes #4778