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.
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
feat: Autofix for W1510 #323
feat: Autofix for W1510 #323
Changes from 3 commits
9a5b437
68e4f5a
45d5abc
13fbbf5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
What happens for multiline?
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.
Good catch.
Might take me a little bit to figure this one out Not sure I have done a multiline fix before.
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.
@karthiknadig , man am i stuck on this.... looks like this won't fit into the regex pattern easily.
I feel like there should be a simpler way for us to add a new parameter to a function call like subprocess.run, any examples of doing something like this anywhere else that we can go off of?
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.
@brettcannon Any recommendation on how we can do this?
Other than actually using a parser to find the right spot, I don't see a way to do this correctly. I honestly think that these change recommendations could be generated from pylint itself. Then all we would have to do is surface them via code actions.
/cc @DanielNoord
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 don't have a way to autofix code directly in pylint right now but we have an open issue for this: pylint-dev/pylint#7438. The fix is certainly going to be easier in the context of pylint where we sometime already display the suggestion in the message... vs by regex here :) We also have a lot on our plate so any help would be greatly appreciated and reviewed promptly.
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.
For a keyword argument, you could find the closing
)
and then prepend to it, but that's assuming you aren't dealing with any nested parentheses. Otherwise you're wading into using theast
module to parse the code, update the AST, and then regenerate the string representation (which even usingast.unparse()
doesn't not guarantee an exact result).Basically you're playing with 🔥 on this one.