__init__.py 965 B

1234567891011121314151617181920212223242526272829303132
  1. """propcache: An accelerated property cache for Python classes."""
  2. from typing import TYPE_CHECKING
  3. _PUBLIC_API = ("cached_property", "under_cached_property")
  4. __version__ = "0.3.1"
  5. __all__ = ()
  6. # Imports have moved to `propcache.api` in 0.2.0+.
  7. # This module is now a facade for the API.
  8. if TYPE_CHECKING:
  9. from .api import cached_property as cached_property # noqa: F401
  10. from .api import under_cached_property as under_cached_property # noqa: F401
  11. def _import_facade(attr: str) -> object:
  12. """Import the public API from the `api` module."""
  13. if attr in _PUBLIC_API:
  14. from . import api # pylint: disable=import-outside-toplevel
  15. return getattr(api, attr)
  16. raise AttributeError(f"module '{__package__}' has no attribute '{attr}'")
  17. def _dir_facade() -> list[str]:
  18. """Include the public API in the module's dir() output."""
  19. return [*_PUBLIC_API, *globals().keys()]
  20. __getattr__ = _import_facade
  21. __dir__ = _dir_facade