Bowler
Bowler copied to clipboard
Failed to parse on **(expr) without parens
This appears to be valid in 3.6, 3.7, and 3.8.0a2:
def func(**kwargs):
print(kwargs)
x = {'a': '1'}
func(**x or {})
Bowler can't parse it, I'm wondering if there is a fissix issue? We should also show the error near "except ParseError" in bowler/tool.py.
This appears to be an issue with lib2to3 on all three versions mentioned above:
from lib2to3.pgen2 import driver
from lib2to3 import pygram, pytree
def main():
with open("t.py") as input:
data = input.read()
d = driver.Driver(
pygram.python_grammar_no_print_statement,
convert=pytree.convert,
)
tree = d.parse_string(data)
print(tree)
if __name__ == '__main__':
main()
https://github.com/python/cpython/pull/12702 and https://github.com/python/cpython/pull/12703 opened upstream for this
This has been fixed in blib2to3
in Black. Maybe I should split it out into its own module, seeing how there's not much interest in backporting changes like https://github.com/python/cpython/pull/6586 and https://github.com/python/cpython/pull/6588