-
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
[pylint] - implement R0202 and R0203 with autofixes #8335
Conversation
603e274
to
33803fa
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
||
let mut diagnostic = Diagnostic::new( | ||
diagnostic_type.clone(), | ||
TextRange::new(stmt.range().start(), stmt.range().start()), |
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 don't really know what range we should highlight with the diagnostic, please advise!
use crate::checkers::ast::Checker; | ||
|
||
/// ## What it does | ||
/// Checks for the use of a classmethod being made without the 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.
It would be nice to add some examples here. Personally I don't even know how you define a classmethod without a decorator. 😊
(just a random observer here who's interested in new Pylint rules, thanks for working on this!)
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.
Ah, my mistake!
I've also had the idea that this could very easily work for And making it a new RUF rule would mean moving some code around to make this reusable between rules, all ears for ideas there. |
Thanks for the contribution! I wonder if people are actually writing class/staticmethods like this still? Would you mind updating with |
7755784
to
41c13a3
Compare
41c13a3
to
f16096e
Compare
|
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!
Summary
Implements
no-classmethod-decorator
/R0202
andno-staticmethod-decorator
/R0203
with autofixes.They're similar enough that all code is reusable for both.
See: #970
Test Plan
cargo test