Invariance vs covariance Invariance vs covariance Most mutable generic collections are invariant, and mypy considers alluser-defined generic classes invariant by default(see Va...
Config file format Config file format The configuration file format is the usualini file format. It should containsection names in square brackets and flag settings of the for...
Type checking Python 2 code Type checking Python 2 code For code that needs to be Python 2.7 compatible, function typeannotations are given in comments, since the function anno...
Check that statement or expression is unreachable [unreachable] Check that statement or expression is unreachable [unreachable] If you use —warn-unreachable , mypy generates a...
Check that type arguments exist [type-arg] Check that type arguments exist [type-arg] If you use —disallow-any-generics , mypy requires that each generictype has values for ea...
Notes about the semantic analyzer Notes about the semantic analyzer Mypy 0.710 introduced a new semantic analyzer, and the old semanticanalyzer was removed in mypy 0.730. Suppo...
Type inference Type inference Mypy considers the initial assignment as the definition of a variable.If you do not explicitlyspecify the type of the variable, mypy infers the ty...
More types More types This section introduces a few additional kinds of types, including NoReturn ,NewType , TypedDict , and types for async code. It also discusseshow to giv...
Reading a list of files from a file Reading a list of files from a file Finally, any command-line argument starting with @ reads additionalcommand-line arguments from the file...
Generic methods and generic self Generic methods and generic self You can also define generic methods — just use a type variable in themethod signature that is different from c...