Description
currently we output a single-line type comment:
def my_func(arg1, arg2, arg3):
# type: (arg1T, arg2T, arg3T) -> returnT
this can get quite long, but even Black will never wrap this comment line
if not all args have documented types then currently we add a type comment which doesn't match the signature, alternatively we should introspect the signature and raise an error
another alternative is to re-format the def
and type comment as:
def my_func(
arg1, # type: arg1T
arg2, # type: arg2T
arg3, # type: arg3T
):
# type: (...) -> returnT
this is better when the comment gets too long
additionally, say arg2
was not typed in the docstring, we can output:
def my_func(
arg1, # type: arg1T
arg2,
arg3, # type: arg3T
):
# type: (...) -> returnT
if we simply omit the arg from our one-line type comment, mypy would rightly give us:
error: Type signature has too few arguments
but with the multi-line format mypy appears to treat the missing annotation as an implicit Any
and will happily type check it as that
Currently if there are missing args we output:
# type (...) -> returnT
i.e. all args become implicit Any
. mypy accepts this, but it's not a good annotation