-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
fix(ruff): adapt to new json output format #916
fix(ruff): adapt to new json output format #916
Conversation
The JSON output format for fixes has changed causing parsing error: > Linting with ruff failed: > Cannot read properties of undefined (reading 'row')
// TODO: Support multiple edits. | ||
const edit = fix.edits[0]; |
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.
Not sure what the best way to support this is. But at least this fixes the immediate parsing error.
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.
By the way, here's an example of a fix with multiple edits:
# foo.py
import subprocess
subprocess.run([], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
$ ruff --format json --select UP foo.py
[
{
"code": "UP022",
"message": "Sending stdout and stderr to pipe is deprecated, use `capture_output`",
"fix": {
"message": "Replace with `capture_output` keyword argument",
"edits": [
{
"content": "capture_output=True",
"location": {
"row": 3,
"column": 19
},
"end_location": {
"row": 3,
"column": 41
}
},
{
"content": "",
"location": {
"row": 3,
"column": 41
},
"end_location": {
"row": 3,
"column": 65
}
}
]
},
"location": {
"row": 3,
"column": 1
},
"end_location": {
"row": 3,
"column": 67
},
"filename": "/tmp/foo.py",
"noqa_row": 3
}
]
Thank you for your PR, the |
support old and new format both close #916
@lithammer sorry for the delay, I made fix in #918, support old and new format both, also supports the multiple edits. # foo.py
import subprocess
subprocess.run([], stdout=subprocess.PIPE, stderr=subprocess.PIPE) to import subprocess
subprocess.run([], capture_output=True) |
support old and new format both close #916
Thanks! Looking back at this, I don't think my fix was correct either. I was using import subprocess
subprocess.run([], Sending stdout and stderr to pipe is deprecated, use `capture_output`) |
The JSON output format for fixes has changed causing parsing error: