On , I learnt ...
That mypy
only type-checks functions that have at least one type annotation
This is noted in the common issues and solutions documentation. For
example mypy
doesn’t complain about this obviously wrong function call:
def cast_int_to_string(x: int) -> str:
return f"{x}"
def main():
cast_int_to_string("x")
but does if we annotate the return type of main
:
def cast_int_to_string(x: int) -> str:
return f"{x}"
def main() -> None:
cast_int_to_string("x")
Hence it’s valuable to annotate None
return types to ensure mypy
type-checks
them.