I've started experimenting with this project and it works really nice so far, but what I find that is missing is the description of the typed AST. For ordinary AST there is some effort going on here: https://greentreesnakes.readthedocs.io/en/latest/nodes.html . However, is there any kind of documentation with regard to how typed_ast.ast35 should look?
E.g. type_comment seems to be treated as just a string. However what is done e.g. in mypy is the type comment is treated as code. Is that intended?
my_string = None # type: typing.Optional[str]
Module(
body=[Assign(
targets=[Name(
id='my_string',
ctx=Store())],
value=NameConstant(value=None),
type_comment='typing.Optional[str]')],
type_ignores=[])
Another example is here, where type annotations are not treated as strings, but are parsed normally:
def function(a: int, b: int) -> int:
return a + b
Module(
body=[FunctionDef(
name='function',
args=arguments(
args=[
arg(
arg='a',
annotation=Name(
id='int',
ctx=Load())),
arg(
arg='b',
annotation=Name(
id='int',
ctx=Load()))],
vararg=None,
kwonlyargs=[],
kw_defaults=[],
kwarg=None,
defaults=[]),
body=[Return(value=BinOp(
left=Name(
id='a',
ctx=Load()),
op=Add(),
right=Name(
id='b',
ctx=Load())))],
decorator_list=[],
returns=Name(
id='int',
ctx=Load()),
type_comment=None)],
type_ignores=[])
I've started experimenting with this project and it works really nice so far, but what I find that is missing is the description of the typed AST. For ordinary AST there is some effort going on here: https://greentreesnakes.readthedocs.io/en/latest/nodes.html . However, is there any kind of documentation with regard to how
typed_ast.ast35should look?E.g.
type_commentseems to be treated as just a string. However what is done e.g. in mypy is the type comment is treated as code. Is that intended?Another example is here, where type annotations are not treated as strings, but are parsed normally: