Skip to content

Unsupported Python Features

Michael Lee edited this page Aug 25, 2016 · 8 revisions

Some Python features are not currently supported by mypy.

It should be relatively easy to add support for these features (and all of these will likely be supported in the future):

  • Properties with setters (currently partial support)
  • Descriptors
  • __setattr__
  • __all__ with imports if the value can be evaluated during compilation (e.g. ['x', 'y', ...])
  • Double underscore name mangling in classes (you can use double underscores but the names are not treated as special)

The features in the list below are more difficult to support. Many of these could be supported, at least in a restricted form, but some will likely remain unsupported.

  • Metaclasses

    • We could have plugin mechanism that would allow mypy to understand specific metaclasses
  • Runtime mutation of classes and modules (be more specific)

  • __all__ with complex initializer / mutated value

  • Class decorators that modify a class

    • Similar to metaclasses
  • Run-time evaluated base class, for example:

    class A(foo()): pass
    
  • eval and exec (these can be used but they are opaque to the type checker)

  • Run-time addition/mutation of base classes (e.g. the abc module)

  • Conditional definition of classes (e.g. within if statement)

    • This could probably be supported for dynamic classes.
  • Certain idioms involving conditional imports

    • These could be supported by delaying binding to runtime (i.e. accessing conditionally imported modules via Any types).