Hacker News new | ask | show | jobs
by ddfisher 3773 days ago
This is intended behavior, actually! By default, mypy doesn't type check the interior of functions that don't have any type annotations. This lets you slowly introduce types to a large codebase without having to convert everything at once (or even file by file). Adding a type annotation to "bar" will cause mypy to check it:

  def foo(n: int):
      pass
  def bar() -> None:
      foo("123")

  >> main: note: In function "bar":
  >> main:4: error: Argument 1 to "foo" has incompatible type "str"; expected "int"