Table of Contents

  1. [2019-10-26 Sat] revealtype can be used during the type checking
  2. [2019-12-07 Sat] hack for preventing unnecessary module imports
  3. [2019-10-27 Sun] how should type of lrucache be defined
  4. [2019-04-16 Tue] The Mypy Blog: Mypy 0.700 Released: Up To 4x Faster

TODO [2019-10-26 Sat] revealtype can be used during the type checking

reveal_type(a) # N: Revealed type is 'builtins.int'

https://github.com/python/mypy/blob/09c243dcc12935b989367f31d1d25d7fd0ec634c/test-data/unit/check-python38.test

[2019-12-07 Sat] hack for preventing unnecessary module imports

Type annotation will require importing modules that you wouldn't need to import without it. However there is now a workaround (quote the name and import in a dead if):

if False:
    from bar_module import bar

def foo(a: 'bar'):
     pass

TODO [2019-10-27 Sun] how should type of lrucache be defined

https://github.com/python/mypy/issues/5107

from typing import TYPE_CHECKING, TypeVar
if TYPE_CHECKING:
    F = TypeVar('F', Callable)
    def lru_cache(f: F) -> F: pass
else:
    from functools import lru_cache

TODO [2019-04-16 Tue] The Mypy Blog: Mypy 0.700 Released: Up To 4x Faster

https://mypy-lang.blogspot.com/2019/04/mypy-0700-released-up-to-4x-faster.html

We are now shipping a mypy binary compiled with mypyc by default, which is up to 4x faster than the interpreted version shipped previously. The compiled version has been available as a separate PyPI distribution for a while now, and this is first release where it’s installed by default. Mypyc is a compiler that compiles type-annotated Python modules into efficient CPython C extension modules.