Merged
Conversation
87800a0 to
068c2f7
Compare
drdavella
previously requested changes
Mar 12, 2024
Member
drdavella
left a comment
There was a problem hiding this comment.
Looks really nice overall, just a few minor comments.
To address your points:
- I think it's okay to use the lack of
@staticmethodto 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
selfandclsare 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.
andrecsilva
requested changes
Mar 12, 2024
9fcef7d to
f3d159e
Compare
Contributor
Author
|
Reviewers: note the change in implementation to correctly handle nested functions. |
f3d159e to
f79021b
Compare
andrecsilva
approved these changes
Mar 15, 2024
Co-authored-by: Dan D'Avella <dan.davella@pixee.ai>
f79021b to
dbfb1fb
Compare
addressed all requested changes from Dan
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




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 caseAby checking ifselfis ever used. Could be a bit tricky. It is less risky to just addselfthan it is to incorrectly assumeselfis never used and making it a staticmethod.Closes #297