Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/propcache/__init__.py: 65%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

17 statements  

1"""propcache: An accelerated property cache for Python classes.""" 

2 

3from typing import TYPE_CHECKING 

4 

5_PUBLIC_API = ("cached_property", "under_cached_property") 

6 

7__version__ = "0.3.2" 

8__all__ = () 

9 

10# Imports have moved to `propcache.api` in 0.2.0+. 

11# This module is now a facade for the API. 

12if TYPE_CHECKING: 

13 from .api import cached_property as cached_property # noqa: F401 

14 from .api import under_cached_property as under_cached_property # noqa: F401 

15 

16 

17def _import_facade(attr: str) -> object: 

18 """Import the public API from the `api` module.""" 

19 if attr in _PUBLIC_API: 

20 from . import api # pylint: disable=import-outside-toplevel 

21 

22 return getattr(api, attr) 

23 raise AttributeError(f"module '{__package__}' has no attribute '{attr}'") 

24 

25 

26def _dir_facade() -> list[str]: 

27 """Include the public API in the module's dir() output.""" 

28 return [*_PUBLIC_API, *globals().keys()] 

29 

30 

31__getattr__ = _import_facade 

32__dir__ = _dir_facade