-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Prevent useless-suppression
on disables for stdlib deprecation checker
#5876
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
Prevent useless-suppression
on disables for stdlib deprecation checker
#5876
Conversation
Pull Request Test Coverage Report for Build 1966122943
💛 - Coveralls |
py-version
settingpy-version
setting
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, this is definitely a checker where the py-version
is very useful.
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.
Looks good. I left a few comments with some more detailed types.
Co-authored-by: Marc Mueller <[email protected]>
Co-authored-by: Marc Mueller <[email protected]>
for more information, see https://pre-commit.ci
Bit late to the party here, but are we sure this should consider |
My reply would be: it's better to divorce these things from your python interpreter. If you haven't (or won't be) upgrading your python interpreter from 3.8 to 3.10, then you can run with The docs should probably be updated to suggest running |
Well, if you have poor test coverage and then never trigger a warning during tests, pylint comes to the rescue! 😉 |
Wow, I think Daniel is right. We probably want to do the opposite change and warn for all versions regardless of the interpreter used. (Edit: We followed the same logic than for the typing checker but in the case of typing you can't use the new typing on old interpreter, but you can always use the new function instead of the deprecated one). |
Agreed, but at the same time it kind of defeats the purpose of this message? A completely (and perhaps equally flawed approach) could be to remove
That runs a bit counter to what that setting is supposed to represent (both in |
Got it, fair enough. But I wonder about other things besides the deprecated checker. What about the
If we warn on all versions for, say, (I'm open to whatever; interested in this for its own sake, not some passionate commitment to any direction.) |
I think it also makes sense to follow the logic used elsewhere (in the typing checker for example).
I like this that way we could both have minimum false negative and false positive. Maybe more generally if a message uses the I don't have a strong opinion about this. I think @cdce8p, as the creator of |
The reason why I added Some points to take away. -- It could even be that exact conflict why we haven't changed it already. So how do we resolve this? Tbh I don't have a good answer here. One moment I like --
Not sure. Wouldn't that defeat the purpose of the |
Thanks, that's helpful. I think now I looked at the original deprecated checker, no discussion about multiple-interpreter projects. Warn for all versions and don't emit useless-suppression for the deprecated checker are not incompatible with each other, but nobody's asking for the former ATM, so I suggest just doing the smaller change to deal with the little bump I ran into. :-) |
py-version
settinguseless-suppression
on disables for stdlib deprecation checker
I think that just comes down to personal preference. Fact remains that a project which uses Another (far-fetched) idea would be to change |
Thank you for the reminder ! Taking that into account if By "emit suggestions, not warnings" are you saying we should decrease the level of the message like @DanielNoord suggested ? I think information message are deactivated by default so if we decrease to |
No, suggestions is just the mental model I use here. As you said, information messages likely wouldn't be seen at all. So those don't help.
Sounds good to me. In your changes, I saw that we already exclude |
pylint/constants.py
Outdated
"W0402", # deprecated-module | ||
"W1505", # deprecated-method | ||
"W1511", # deprecated-argument | ||
"W1512", # deprecated-class | ||
"W1513", # deprecated-decorator |
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'm wondering how hard it would be to still raise useless-suppression if the function/class/module/decorator... is not deprecated in any python version. I don't think this checker is very performance intensive, maybe relaunching with the highest python version (3.10 right now) is possible ?
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.
Though about something similar, but in the context of a bare disable
once the deprecation has been removed.
I don't think this checker is very performance intensive, maybe relaunching with the highest python version (3.10 right now) is possible ?
Not sure that is practical. It would almost certainly change major parts of the application flow.
Maybe it's simpler to add a new config option to show all useless-suppression
messages? We should mention however, that it should only be used temporarily and not added to pylintrc
.
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.
@cdce8p I like your last suggestion!
Thanks for the reviews -- they helped point this in the right direction and get it polished.
Shall we defer that to another issue? |
👍🏻 |
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.
Looks good to me. I'll leave the final call for @DanielNoord and @Pierre-Sassoulas.
Thanks @jacobtylerwalls 🐬
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 @jacobtylerwalls!
Could you make that follow-up issue about finding an elegant way to force useless-suppression
to show all warnings?
Type of Changes
Description
Before
The deprecated names checker ignored thepy_version
setting, raising warnings (or not) depending on the python interpreter version.useless-suppression
is raised on disables ofdeprecated-module
and sim. on lower versions where the module is not yet deprecated. This can make it challenging to get a project to pass pylint on multiple versions with a disable for a deprecated module.Now
Deprecated name warnings are emitted according topy_version
(which falls back to the interpreter version).Discussed at #5874 (comment).useless-suppression
is treated as incompatible with the stdlib deprecation checks--it is not emitted.Tangent
As a follow up, we could consider adding
After 2.13, I suppose it should be--py-version=3.8
to the pre-commit config to match CI?--py-version=3.7
.