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
ast.parse = parse(source, filename='<unknown>', mode='exec', *, type_comments=False, feature_version=None)
Parse the source into an AST node.
Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
Pass type_comments=True to get back type comments where the syntax allows.
The text was updated successfully, but these errors were encountered:
After some investigation, it seems that type comments are mainly used in backporting type functionality into Python 2. Python 3 uses type annotations and we actually already use them at least for function return types and argument types.
Example for a type comment (This is parsed as an Assign with type_comment:
a=42# type int
Example for a type annotation on variable (this is parsed as an AnnAssign with annotation:
a: int=42
Example for type annotation on function (this is parsed as returns on the FunctionDef as well as annotation on the arg):
defbar(x: int) ->int: ...
We currently only support parsing the last one, but in order to get as much type information as possible we should probably support all.
Investigate and make it work.
The text was updated successfully, but these errors were encountered: