Configuring mypy
Mypy supports many command line options that you can use to tweak howmypy behaves: see The mypy command line for more details.
For example, suppose you want to make sure all functions within yourcodebase are using static typing and make mypy report an error if youadd a dynamically-typed function by mistake. You can make mypy do thisby running mypy with the —disallow-untyped-defs
flag.
Another potentially useful flag is —strict
, which enables many(though not all) of the available strictness options – including—disallow-untyped-defs
.
This flag is mostly useful if you’re starting a new project from scratchand want to maintain a high degree of type safety from day one. However,this flag will probably be too aggressive if you either plan on usingmany untyped third party libraries or are trying to add static types toa large, existing codebase. See Using mypy with an existing codebase for more suggestionson how to handle the latter case.