-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Distinguish between genuine typos and old configuration that could be cleaned in configuration warning #6824
Conversation
4968b40
to
c48188a
Compare
pylint/constants.py
Outdated
], | ||
"https://pylint.pycqa.org/en/latest/whatsnew/1/1.4.html#what-s-new-in-pylint-1-4-3": [ | ||
DeletedMessage("R0921", "abstract-class-not-used"), | ||
DeletedMessage("R0922", "abstract-class-little-used"), |
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 was not documented before, I had to dig a little.
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.
Well done on finding a nice fix for this. This does indeed seem like a good middle-ground.
And well done on finding those old messages.
Some earlier comments before I do a full review/
pylint/lint/message_state_handler.py
Outdated
@@ -411,9 +412,14 @@ def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None: | |||
try: | |||
meth(msgid, "module", l_start) | |||
except exceptions.UnknownMessageError: |
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 just wonder, there are more place where we catch this exception. Should we also add this special handling there?
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.
Well, something really elegant would be to reraise a DeletedMessageError
with the justification...
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.
Or pass the linter to the Error and add the message from the error itself?
return explanation | ||
return None | ||
|
||
def kwargs_for_bad_option_value_add_message( |
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.
Let's make both of these private while we haven't documented our public API specifically.
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.
We're using it in PyLinter ourself so it's complicated to make them private. I'm also ok with poeple using the is_deleted_msgid_or_symbol
as a public API. What about making kwargs_for_bad_option_value_add_message
protected ?
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 think private means private to the package owner. I have used underscores to denote stuff as private but then used that in other places too. As long as it is all within the same package you can't really change stuff without immediately noticing something breaks.
is_deleted_msgid_or_symbol
seems like a good utility method but I just worry that down the line we might want to change stuff to it or use a completely different method of raising these messages. After the issues we had with stuff unintentionally breaking in 2.12
and 2.13
I'm just like: as long as nobody asks for it, nobody needs it and we should just keep it to ourselves to make it easier to change stuff later on.
@@ -1,3 +1,3 @@ | |||
************* Module {abspath} | |||
{relpath}:1:0: E0012: Bad option value for --disable. Don't recognize message logging-not-lazylogging-format-interpolation. (bad-option-value) | |||
{relpath}:1:0: E0012: Bad option value for --enable. Don't recognize message locally-disabledsuppressed-message. (bad-option-value) | |||
{relpath}:1:0: E0012: Bad option value for '--disable'. Don't recognize message 'logging-not-lazylogging-format-interpolation'. (bad-option-value) |
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.
We should probably join the messages with a comma.
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.
@Pierre-Sassoulas My bad, I meant the message that we don't recognise π
But the comma you added now is also a good changed imo π
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.
Ho π well this is the content of the test, if it was properly joined with a comma there would not be a bad-option-value raised. It's admittedly a little too close to what happen in real life ezczeczasxaz
would have the same effect.
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.
Oops, I was looking at another test just above it and thought they were connected. This is indeed correct.
Pull Request Test Coverage Report for Build 2446419315
π - Coveralls |
This comment has been minimized.
This comment has been minimized.
52911fd
to
6b0df75
Compare
The primer actually find something interesting in astroid, we can't use parenthesis to justify a pragma. We had a discussion about this but I think we should just fix this in 2.14.1 and do better later. |
This comment has been minimized.
This comment has been minimized.
Should be fixed with an additional #. Other tools require this as well, so I don't think it's too big of an issue. I believe mypy doesn't even recognise its disables if they come after an pylint disable. They want priority π |
5f88740
to
d21ce04
Compare
This comment has been minimized.
This comment has been minimized.
6d5b9c9
to
d98b0ee
Compare
This comment has been minimized.
This comment has been minimized.
Sorry to make changes after your review @jacobtylerwalls, but I figured:
So I'm going to add a new commit using |
@Pierre-Sassoulas I'd advise against making this an |
621effb
to
2559ee2
Compare
Yeah, one of them should keep |
In fact the only other messages used multiple time as old_name is |
I was more referring to messages that are related but are on different levels. To take |
b142c9d
to
d7fc85b
Compare
Sorry for rebasing but I think the commits need to be separated. I renamed R0012 to R0022 (first number not used elsewhere in main checker). |
d7fc85b
to
adbceae
Compare
This comment has been minimized.
This comment has been minimized.
adbceae
to
50b1dc2
Compare
This comment has been minimized.
This comment has been minimized.
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.
Just some initial review. If you're able to perhaps split some changes from this PR. There is a lot going on, with some of it just being general refactoring. Makes it quite hard to review this.
After all the opened issues I'd like to get this right once and for all.
doc/test_messages_documentation.py
Outdated
@@ -71,7 +73,6 @@ def get_functional_test_files_from_directory(input_dir: Path) -> List[Tuple[str, | |||
class LintModuleTest: | |||
def __init__(self, test_file: Tuple[str, Path]) -> None: | |||
self._test_file = test_file |
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 is probably your IDE but your PRs keep removing white lines. This is just personal preferences, but I kinda like how white lines can separate different elements within a function.
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.
Haha no, it's personal preference, imo compactness is good for readability, I think creating smaller code unit with functions also make more sense if something need to be separated. Anyway I'm going to stop doing that if you don't like it as we don't need churn around this.
Right let's start by #6866 |
7973401
to
e9b28c3
Compare
e9b28c3
to
02b3d7c
Compare
Then #6867. Even if we don't need to activate the old messages there was still some things to keep there. |
This comment has been minimized.
This comment has been minimized.
So it's possible to to distinguish between genuine typoes and old configuration that could be cleaned. We use old_names to decrease message type to warning
02b3d7c
to
18bb1ee
Compare
Previousely they were considered unknown names.
18bb1ee
to
c5f0ce1
Compare
π€ Effect of this PR on checked open source code: π€ Effect on astroid:
The following messages are no longer emitted:
This comment was generated for commit c5f0ce1 |
Type of Changes
Description
Deleted messages that do not exists anymore in pylint now raise
useless-option-value
instead ofbad-option-value
which permit to distinguish between genuine typoes and old configuration that could be cleaned.
Refs #6794, #6514 ... and 2 or 3 other issues opened recently. There's also question on stackoverflow about this.
For example:
https://stackoverflow.com/questions/72486567/
https://stackoverflow.com/questions/72478704/