-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
"""propcache: An accelerated property cache for Python classes.""" | ||
|
||
from typing import TYPE_CHECKING, List | ||
|
||
__version__ = "1.0.0" | ||
|
||
# Imports have moved to `propcache.api` in 1.0.0+. | ||
__all__ = () | ||
# This module is now a facade for the API. | ||
if TYPE_CHECKING: | ||
from .api import cached_property, under_cached_property | ||
|
||
__all__ = ("cached_property", "under_cached_property") | ||
|
||
|
||
def _import_facade(attr: str) -> object: | ||
"""Import the public API from the `api` module.""" | ||
if attr in __all__: | ||
from . import api # pylint: disable=import-outside-toplevel | ||
|
||
return getattr(api, attr) | ||
raise AttributeError(f"module 'propcache' has no attribute '{attr}'") | ||
|
||
|
||
def _dir_facade() -> List[str]: | ||
"""Include the public API in the module's dir() output.""" | ||
return [*__all__, *globals().keys()] | ||
|
||
|
||
__getattr__ = _import_facade | ||
__dir__ = _dir_facade |