Type annotation for variables in function
gretadolcetti opened this issue · comments
I am usining pytype to get type annotation for a given Python program.
For example for program test.py
a = 1
b = 1.0
after executing pytype test.py
and merge-pyi test.py .pytype/pyi/test.pyi
I obtain
a: int = 1
b: float = 1.0
which is the desired output.
But when pytype analyzes a function. it only annotates the return type of the function and not the variables inside it (even though I think this information is stored and used somewhere).
For example when I analyze
def foo():
a = 1
return a
I obtain
def foo() -> int:
a = 1
return a
but what I really would like to obtain is
def foo() -> int:
a: int = 1
return a
Is there any option to obtain this?
Thanks for the question! Unfortunately, merge-pyi only merges in types that appear in .pyi files, which doesn't include local variables inside functions.