-
Notifications
You must be signed in to change notification settings - Fork 10
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
New codemod to add missing self
/cls
#355
Conversation
87800a0
to
068c2f7
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.
Looks really nice overall, just a few minor comments.
To address your points:
- I think it's okay to use the lack of
@staticmethod
to infer intent here, but obviously there might be a small set of cases where we'd be wrong - Doing this when other arguments are present would be really cool but it does seem challenging. Unfortunately since
self
andcls
are not actually keywords it becomes pretty hard to tell what was actually intended in those cases, although probably in 99% of cases our fix would be okay.
9fcef7d
to
f3d159e
Compare
Reviewers: note the change in implementation to correctly handle nested functions. |
f3d159e
to
f79021b
Compare
Co-authored-by: Dan D'Avella <[email protected]>
f79021b
to
dbfb1fb
Compare
addressed all requested changes from Dan
Quality Gate passedIssues Measures |
Overview
A codemod that checks if instance/class methods without any args need self/cls
Description
__new__
and__init_subclass__
sonar mentionsself
/cls
?self
. However, another valid change would be to make it a@staticmethod
. For example:Right now we handle both cases the same: just add
self
. However, we could decide to handle for caseA
by checking ifself
is ever used. Could be a bit tricky. It is less risky to just addself
than it is to incorrectly assumeself
is never used and making it a staticmethod.Closes #297