Right now static typing isn't really supported, and we are basically forced to turn it off via
from cached_property import cached_property # type: ignore
What seems to work pretty well is to pretend to mypy that cached_property is the same as property, that is, write a cached_property.pyi stub file with just
cached_property = property
and then manually point mypy at it. Ideally that would be part of the out-of-the-box experience. For that we would need to either push support into typeshed or:
- Rewrite cached_property.py into a package (code goes into
cached_property/__init__.py or import it from there)
- Add the
cached_property/__init__.pyi stub
- Add the
cached_property/py.typed marker as in https://www.python.org/dev/peps/pep-0561/
With #26 we wouldn't need the stub pyi file but the py.typed marker and refactoring into a package would still be required.
Right now static typing isn't really supported, and we are basically forced to turn it off via
What seems to work pretty well is to pretend to mypy that cached_property is the same as property, that is, write a
cached_property.pyistub file with justand then manually point mypy at it. Ideally that would be part of the out-of-the-box experience. For that we would need to either push support into typeshed or:
cached_property/__init__.pyor import it from there)cached_property/__init__.pyistubcached_property/py.typedmarker as in https://www.python.org/dev/peps/pep-0561/With #26 we wouldn't need the stub pyi file but the
py.typedmarker and refactoring into a package would still be required.