Skip to content
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

YapfBear: Catch errors and make a result #750

Closed
underyx opened this issue Aug 31, 2016 · 6 comments
Closed

YapfBear: Catch errors and make a result #750

underyx opened this issue Aug 31, 2016 · 6 comments

Comments

@underyx
Copy link
Member

underyx commented Aug 31, 2016

When trying this test case: self.check_validity(self.uut, ['async def x():\n', '0\n'], valid=True)

I got a traceback:

Bear YapfBear failed to run. Take a look at debug messages (`-L DEBUG`) for further information.
The bear YapfBear raised an exception. If you are the writer of this bear, please make sure to catch all exceptions. If not and this error annoys you, you might want to get in contact with the writer of this bear.

Traceback information is provided below:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/yapf/yapflib/pytree_utils.py", line 101, in ParseCodeToTree
    tree = parser_driver.parse_string(code, debug=False)
  File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib2to3/pgen2/driver.py", line 106, in parse_string
    return self.parse_tokens(tokens, debug)
  File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib2to3/pgen2/driver.py", line 71, in parse_tokens
    if p.addtoken(type, value, (prefix, start)):
  File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib2to3/pgen2/parse.py", line 159, in addtoken
    raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=2, value='0', context=('', (2, 0))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/yapf/yapflib/pytree_utils.py", line 107, in ParseCodeToTree
    tree = parser_driver.parse_string(code, debug=False)
  File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib2to3/pgen2/driver.py", line 106, in parse_string
    return self.parse_tokens(tokens, debug)
  File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib2to3/pgen2/driver.py", line 71, in parse_tokens
    if p.addtoken(type, value, (prefix, start)):
  File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib2to3/pgen2/parse.py", line 159, in addtoken
    raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=2, value='0', context=('', (2, 0))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/coalib/bears/Bear.py", line 250, in execute
    return [] if result is None else list(result)
  File "/Users/underyx/coala-bears/bears/python/YapfBear.py", line 146, in run
    verify=False)[0].splitlines(True)
  File "/usr/local/lib/python3.5/site-packages/yapf/yapflib/yapf_api.py", line 90, in FormatFile
    verify=verify)
  File "/usr/local/lib/python3.5/site-packages/yapf/yapflib/yapf_api.py", line 123, in FormatCode
    tree = pytree_utils.ParseCodeToTree(unformatted_source)
  File "/usr/local/lib/python3.5/site-packages/yapf/yapflib/pytree_utils.py", line 113, in ParseCodeToTree
    raise e
  File "/usr/local/lib/python3.5/site-packages/yapf/yapflib/pytree_utils.py", line 111, in ParseCodeToTree
    ast.parse(code)
  File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 2
    0
    ^
IndentationError: expected an indented block
@gitmate-bot
Copy link
Collaborator

Thanks for reporting this issue! A coalaian will look at it soon.

@underyx
Copy link
Member Author

underyx commented Aug 31, 2016

@sils1297 you sillyhead this is just the verbose logging :D close?

(He told me to post this issue and I didn't know any better :D)

@AbdealiLoKo
Copy link
Contributor

Are you sure this is with debug on ?
It says Take a look at debug messages (-L DEBUG) for further information. on top => it is not already in -L DEBUG

@underyx
Copy link
Member Author

underyx commented Aug 31, 2016

I'm not sure what happened behind the scenes — I just ran pytest.

On Wed, Aug 31, 2016 at 7:53 PM AbdealiJK notifications@github.com wrote:

Are you sure this is with debug on ?
It says Take a look at debug messages (-L DEBUG) for further information.
on top => it is not already in -L DEBUG


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#750 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABAuVDQD3hJsNJuDILf8ccqcnBcFsgdyks5qlb94gaJpZM4Jx2CP
.

@sils
Copy link
Member

sils commented Aug 31, 2016

our test execution functions automatically capture the debug logs for you :)

@sils
Copy link
Member

sils commented Aug 31, 2016

the -L DEBUG hint gets shown even if it's already active

@AbdealiLoKo AbdealiLoKo changed the title YapfBear: Lets through yapf's exceptions YapfBear: Catch errors and make a result Aug 31, 2016
@AbdealiLoKo AbdealiLoKo self-assigned this Sep 2, 2016
AbdealiLoKo added a commit that referenced this issue Sep 2, 2016
The YapfBear earlier raised an error when the file was not parseable.
Now, that error is caught and a Result is given out mentioning that the
file has syntax errors and cannot be parsed.

Fixes #750
AbdealiLoKo added a commit that referenced this issue Sep 3, 2016
The YapfBear earlier raised an error when the file was not parseable.
Now, that error is caught and a Result is given out mentioning that the
file has syntax errors and cannot be parsed.

Fixes #750
AbdealiLoKo added a commit that referenced this issue Sep 3, 2016
The YapfBear earlier raised an error when the file was not parseable.
Now, that error is caught and a Result is given out mentioning that the
file has syntax errors and cannot be parsed.

Fixes #750
@rultor rultor closed this as completed in dc3d2ec Sep 3, 2016
AbdealiLoKo added a commit that referenced this issue Sep 3, 2016
The YapfBear earlier raised an error when the file was not parseable.
Now, that error is caught and a Result is given out mentioning that the
file has syntax errors and cannot be parsed.

Fixes #750
gosom pushed a commit to gosom/coala-bears that referenced this issue Jul 15, 2017
The YapfBear earlier raised an error when the file was not parseable.
Now, that error is caught and a Result is given out mentioning that the
file has syntax errors and cannot be parsed.

Fixes coala#750
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants