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

python3: f-string causes "Bear YapfBear failed" #6118

Open
Pajinek opened this issue Mar 26, 2020 · 6 comments
Open

python3: f-string causes "Bear YapfBear failed" #6118

Pajinek opened this issue Mar 26, 2020 · 6 comments

Comments

@Pajinek
Copy link

Pajinek commented Mar 26, 2020

Traceback when new format of f-string is used in Python 3: version 0.12.0.dev99999999999999

Example:

example = "hello"
str = f"{example}"  
  File "/coala/coalib/bears/Bear.py", line 282, in execute
    return [] if result is None else list(result)
  File "/coala-bears/bears/python/YapfBear.py", line 155, in run
    ''.join(file), style_config=fname)[0].splitlines(True)
  File "/usr/lib/python3.6/site-packages/yapf/yapflib/yapf_api.py", line 126, in FormatCode
    tree = pytree_utils.ParseCodeToTree(unformatted_source)
  File "/usr/lib/python3.6/site-packages/yapf/yapflib/pytree_utils.py", line 108, in ParseCodeToTree
    tree = parser_driver.parse_string(code, debug=False)
  File "/usr/lib64/python3.6/lib2to3/pgen2/driver.py", line 106, in parse_string
    return self.parse_tokens(tokens, debug)
  File "/usr/lib64/python3.6/lib2to3/pgen2/driver.py", line 71, in parse_tokens
    if p.addtoken(type, value, (prefix, start)):
  File "/usr/lib64/python3.6/lib2to3/pgen2/parse.py", line 159, in addtoken
    raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=3, value='"www.{HOSTNAME}"', context=('', (20, 28))
Executing section all.python.docs...
@SanketDG
Copy link
Member

f-strings are available from python version 3.6, what version are you using?

@Pajinek
Copy link
Author

Pajinek commented Mar 26, 2020

My code is written in Python 3.7. And I use for check coala by docker image:

docker run -ti --rm -v '${CURDIR}:/app:Z' -w /app coala/base coala -an

@cathlinlord
Copy link

As part of a computer science course, my team and I are working towards contributing to open source code. If possible, we would like to work on this issue. Thanks!

@stephensonc
Copy link

stephensonc commented Apr 16, 2020

@Pajinek, I am a member of the team that @cathlinlord mentioned and have been investigating this issue. It would seem as though the issue stems from the lib2to3 module of python 3.6 not parsing f-strings correctly as documented here.

It is using the 3.6 version of lib2to3 because the docker base image on DockerHub is outdated. The dockerfile in the docker-coala-base repository is set to use python 3.6. Part of the difficulty in updating the dockerfile stems from OpenSUSE Tumbleweed no longer containing/supporting the binary for python 3.6, as seen here.

@Fusion-Pie
Copy link

Hey! I will really like to work on this issue. I will try my best to solve this issue if I get assigned to it. Thank you

@abhishalya
Copy link
Member

@Fusion-Pie No assignment required, feel free to work on this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants