Check that function does not return Any value [no-any-return]

If you use —warn-return-any, mypy generates an error if you return avalue with an Any type in a function that is annotated to return anon-Any value.

Example:

  1. # mypy: warn-return-any
  2.  
  3. def fields(s):
  4. return s.split(',')
  5.  
  6. def first_field(x: str) -> str:
  7. # Error: Returning Any from function declared to return "str" [no-any-return]
  8. return fields(x)[0]