Closed elvslv closed 6 years ago
If a function's arguments are annotated, but return type is missing, for example:
def foo( arg1, # type: Optional[int] arg2, # type: Optional[str] ): return "result"
PyAnnotate ignores existing annotations, and adds a separate one:
def foo( arg1, # type: Optional[int] arg2, # type: Optional[str] ): # type: (None, None) -> str return "result"
Moreover, if we have more arguments,
def foo( argument1, # type: Optional[int] argument2, # type: Optional[str] argument3, # type: Optional[str] argument4, # type: Optional[str] argument5, # type: Optional[str] argument6, # type: Optional[str] ): return "result"
is annotated as
def foo( argument1, # type: None # type: Optional[int] argument2, # type: None # type: Optional[str] argument3, # type: None # type: Optional[str] argument4, # type: None # type: Optional[str] argument5, # type: None # type: Optional[str] argument6, # type: None # type: Optional[str] ): # type: (...) -> str return "result"
Thanks for reporting this! Looks like the check for existing annotations only looks for short-form annotations (at the top of the block) and doesn't know about long-form (per arg) annotations.
If a function's arguments are annotated, but return type is missing, for example:
PyAnnotate ignores existing annotations, and adds a separate one:
Moreover, if we have more arguments,
is annotated as