You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See the main function. The tool doesn't like context managers separated with commas.
However, my question is not about unsupported language features, but rather about error reporting. This is what I see as the output. (Truncated to make it more readable.)
> yapf context.py
Traceback (most recent call last):
...
raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=1, value='as', context=('', (16, 20))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
...
raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=1, value='as', context=('', (16, 20))
During handling of the above exception, another exception occurred:
...
return'{}:{}:{}: {}'.format(e.args[1][0], e.args[1][1], e.args[1][2], e.msg)
IndexError: tuple index out of range
During handling of the above exception, another exception occurred:
...
return'{}:{}:{}: {}'.format(e.args[1][0], e.args[1][1], e.args[1][2], e.msg)
IndexError: tuple index out of range
Unfortunately, none of these lines tell you where exactly this parsing error happened.
I've stumbled upon this kind of error multiple times already, with different language features being unsupported by a version of yapf used at that time. Updating the version usually helps, but it would be nice to see files that break the tool. We use yapf as a pre-commit hook, and it might be difficult to find what exactly fails when there are multiple files changed in a pull request. Seeing the origin of the error would help to roll back to supported syntax until the tool is updated to a newer version.
The text was updated successfully, but these errors were encountered:
devforfu
changed the title
Better error reporting when yapf encounters unsupported Python syntax
Improve error reporting when yapf encounters unsupported Python syntax
Jan 5, 2024
I've encountered a problem with
yapf==0.32
when processing code with multiple context managers. Here is an example.See the
main
function. The tool doesn't like context managers separated with commas.However, my question is not about unsupported language features, but rather about error reporting. This is what I see as the output. (Truncated to make it more readable.)
Unfortunately, none of these lines tell you where exactly this parsing error happened.
I've stumbled upon this kind of error multiple times already, with different language features being unsupported by a version of
yapf
used at that time. Updating the version usually helps, but it would be nice to see files that break the tool. We useyapf
as a pre-commit hook, and it might be difficult to find what exactly fails when there are multiple files changed in a pull request. Seeing the origin of the error would help to roll back to supported syntax until the tool is updated to a newer version.The text was updated successfully, but these errors were encountered: