Supported Python features - mypy 1.16.0+dev.bd1f51ac4de637ab1cbe9f633cdd401d0b520112 documentation (original) (raw)
Toggle table of contents sidebar
A list of unsupported Python features is maintained in the mypy wiki:
Runtime definition of methods and functions¶
By default, mypy will complain if you add a function to a class or module outside its definition – but only if this is visible to the type checker. This only affects static checking, as mypy performs no additional type checking at runtime. You can easily work around this. For example, you can use dynamically typed code or values withAny
types, or you can use setattr() or other introspection features. However, you need to be careful if you decide to do this. If used indiscriminately, you may have difficulty using static typing effectively, since the type checker cannot see functions defined at runtime.