Check that called function returns a value [func-returns-value] Check that called function returns a value [func-returns-value] Mypy reports an error if you call a function wit...
Compatibility of container types Compatibility of container types The following program generates a mypy error, since List[int] is not compatible with List[object] : def f ( ...
The typing module The typing module So far, we’ve added type hints that use only basic concrete types likestr and float . What if we want to express more complex types,such as...
Advanced options Advanced options These options may only be set in the global section ([mypy] ). pdb (bool, default False) Invokes pdb on fatal error. show_traceback (bool,...
Additional notes Additional notes You should include types for arguments with default values in theannotation. The opt argument of method in the example at thebeginning of t...
Incompatible overrides Incompatible overrides It’s unsafe to override a method with a more specific argument type, as it violatesthe Liskov substitution principle . For return ...
Check that attribute exists [attr-defined] Check that attribute exists [attr-defined] Mypy checks that an attribute is defined in the target class or modulewhen using the dot o...
Covariant subtyping of mutable protocol members is rejected Covariant subtyping of mutable protocol members is rejected Mypy rejects this because this is potentially unsafe.Con...
Built-in types Built-in types from typing import List , Set , Dict , Tuple , Optional # For simple built-in types, just use the name of the type x : int = ...
Parameterizing Literals Parameterizing Literals Literal types may contain one or more literal bools, ints, strs, bytes, andenum values. However, literal types cannot contain a...