Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mypy / static typing #172

Open
vbraun opened this issue Aug 11, 2019 · 0 comments
Open

Support mypy / static typing #172

vbraun opened this issue Aug 11, 2019 · 0 comments

Comments

@vbraun
Copy link
Contributor

vbraun commented Aug 11, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant