Unnecessary calling of lib2to3? aka yet another ParseError on Python3
- Dominant language
- Python
- Stars
- 14k
- Forks
- 904
- PR merge metrics
- No merged PRs in 30d
Description
This code seems to trigger a hissyfit from lib2to3 (I am running under Python3.5):
```
headers = {'custom-header': 'foo'}
headers = {**{'Authorization': 'token'}, **headers}
```
```
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/yapf/yapflib/pytree_utils.py", line 103, in ParseCodeToTree
tree = parser_driver.parse_string(code, debug=False)
File "/usr/lib/python3.5/lib2to3/pgen2/driver.py", line 106, in parse_string
return self.parse_tokens(tokens, debug)
File "/usr/lib/python3.5/lib2to3/pgen2/driver.py", line 71, in parse_tokens
if p.addtoken(type, value, (prefix, start)):
File "/usr/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=36, value='**', context=('', (129, 15))
```
Sure enough also the 2to3 tool crashes and burns. What I'm wondering about is, why are we even pushing python3 code through 2to3? Does it not seem inevitable that it will die with new features it doesn't understand? Could there be a .style.yapf option to say python3 = True that would skip running through lib2to3 since obviously it doesn't need conversion from 2 to 3?
Contributor guide
Assessment
This issue has not been assessed yet.