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
Bug in TypedDict AST parsing running on Python 3.10. Runs fine during running of Python application/web server with no output. Black and isort formatting doesn't have a problem either. Example code:
pyupgrade................................................................Failed
- hook id: pyupgrade
- exit code: 1
Traceback (most recent call last):
File "/Users/andrewcwang/.cache/pre-commit/repoof0hoxn7/py_env-python3.10/bin/pyupgrade", line 8, in <module>
sys.exit(main())
File "/Users/andrewcwang/.cache/pre-commit/repoof0hoxn7/py_env-python3.10/lib/python3.10/site-packages/pyupgrade/_main.py", line 381, in main
ret |= _fix_file(filename, args)
File "/Users/andrewcwang/.cache/pre-commit/repoof0hoxn7/py_env-python3.10/lib/python3.10/site-packages/pyupgrade/_main.py", line 318, in _fix_file
contents_text = _fix_plugins(
File "/Users/andrewcwang/.cache/pre-commit/repoof0hoxn7/py_env-python3.10/lib/python3.10/site-packages/pyupgrade/_main.py", line 80, in _fix_plugins
callback(i, tokens)
File "/Users/andrewcwang/.cache/pre-commit/repoof0hoxn7/py_env-python3.10/lib/python3.10/site-packages/pyupgrade/_plugins/typing_classes.py", line 143, in _fix_dict_typed_dict
end, attrs = _typed_class_replacement(tokens, i, call, types)
File "/Users/andrewcwang/.cache/pre-commit/repoof0hoxn7/py_env-python3.10/lib/python3.10/site-packages/pyupgrade/_plugins/typing_classes.py", line 84, in _typed_class_replacement
member = f'{indent}{k}: {_unparse(v)}'
File "/Users/andrewcwang/.cache/pre-commit/repoof0hoxn7/py_env-python3.10/lib/python3.10/site-packages/pyupgrade/_plugins/typing_classes.py", line 39, in _unparse
slice_s = _unparse(node_slice)
File "/Users/andrewcwang/.cache/pre-commit/repoof0hoxn7/py_env-python3.10/lib/python3.10/site-packages/pyupgrade/_plugins/typing_classes.py", line 52, in _unparse
raise NotImplementedError(ast.dump(node))
NotImplementedError: Call(func=Name(id='TypedDict', ctx=Load()), args=[Constant(value='query'), Dict(keys=[Constant(value='branches')], values=[Subscript(value=Name(id='list', ctx=Load()), slice=Call(func=Name(id='TypedDict', ctx=Load()), args=[Constant(value='branches'), Dict(keys=[Constant(value='branches')], values=[Subscript(value=Name(id='list', ctx=Load()), slice=Call(func=Name(id='TypedDict', ctx=Load()), args=[Constant(value='branches'), Dict(keys=[Constant(value='branches')], values=[Subscript(value=Name(id='list', ctx=Load()), slice=Call(func=Name(id='TypedDict', ctx=Load()), args=[Constant(value='branches'), Dict(keys=[Constant(value='count')], values=[Name(id='int', ctx=Load())])], keywords=[]), ctx=Load())])], keywords=[]), ctx=Load())])], keywords=[]), ctx=Load())])], keywords=[])
The text was updated successfully, but these errors were encountered:
Andrew-Chen-Wang
changed the title
Cyclical TypedDict produces AST error on Python 3.10
Embedded TypedDict produces AST error on Python 3.10
Mar 11, 2023
Bug in TypedDict AST parsing running on Python 3.10. Runs fine during running of Python application/web server with no output. Black and isort formatting doesn't have a problem either. Example code:
Pre-commit file
Stacktrace
The text was updated successfully, but these errors were encountered: