Check that every function has an annotation [no-untyped-def]

If you use —disallow-untyped-defs, mypy requires that all functionshave annotations (either a Python 3 annotation or a type comment).

Example:

  1. # mypy: disallow-untyped-defs
  2.  
  3. def inc(x): # Error: Function is missing a type annotation [no-untyped-def]
  4. return x + 1
  5.  
  6. def inc_ok(x: int) -> int: # OK
  7. return x + 1
  8.  
  9. class Counter:
  10. # Error: Function is missing a type annotation [no-untyped-def]
  11. def __init__(self):
  12. self.value = 0
  13.  
  14. class CounterOk:
  15. # OK: An explicit "-> None" is needed if "__init__" takes no arguments
  16. def __init__(self) -> None:
  17. self.value = 0