[issue43609] ast.unparse-ing a FunctionType gives ambiguous result

2021-03-26 Thread Batuhan Taskaya
Batuhan Taskaya added the comment: > @BTaskaya I've seen this in third party ides and type checker. For example > they are referring to "Union[Callable[[], Union[int, str]], None]" as "() -> > (int | str) | None" where there are parentheses around the returns. Though you can not simple

[issue43609] ast.unparse-ing a FunctionType gives ambiguous result

2021-03-25 Thread midori
midori added the comment: @BTaskaya I've seen this in third party ides and type checker. For example they are referring to "Union[Callable[[], Union[int, str]], None]" as "() -> (int | str) | None" where there are parentheses around the returns. --

[issue43609] ast.unparse-ing a FunctionType gives ambiguous result

2021-03-25 Thread Batuhan Taskaya
Batuhan Taskaya added the comment: Hey @cleoold! Technically the second AST you gave is invalid (fun2), considering that the FunctionType is not an expression; mod = Module(stmt* body, type_ignore* type_ignores) | FunctionType(expr* argtypes, expr returns) expr =

[issue43609] ast.unparse-ing a FunctionType gives ambiguous result

2021-03-23 Thread midori
New submission from midori : Hi all, this is probably my first issue here, so don't blame me if I do something wrong lol The ast.FunctionType gives syntax like (a, b) -> c for function types, this is ok, and also since Python 3.10 we can use X | Y to denote unions, this is ok. So Given the