[issue44825] node.annotation is not a str in `ast`'s `class _Unparser(NodeVisitor)`
Samuel Marks
report at bugs.python.org
Wed Aug 4 05:57:23 EDT 2021
Samuel Marks <samuelmarks at gmail.com> added the comment:
Hmm, debugging my test and I was able to replicate it with this smaller one:
```
from ast import FunctionDef, arguments, Load, Name, AnnAssign, Store, BinOp, Add, unparse
unparse(FunctionDef(args=arguments(args=[],
defaults=[],
kw_defaults=[],
kwarg=None,
kwonlyargs=[],
posonlyargs=[],
vararg=None),
body=[AnnAssign(annotation='int',
simple=1,
target=Name(ctx=Store(),
id='res'),
value=BinOp(left=Name(ctx=Load(),
id='a'),
op=Add(),
right=Name(ctx=Load(),
id='b')))],
decorator_list=[],
name='sum',
returns=None,
lineno=None,
type_comment=None))
```
Which for some reason has made the `annotation` a `str` rather than `Name`. So I think it's my bug then?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44825>
_______________________________________
More information about the Python-bugs-list
mailing list