diff options
author | Jordan Cook <jordan.cook@pioneer.com> | 2021-10-26 16:37:39 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook@pioneer.com> | 2021-10-27 10:35:39 -0500 |
commit | 90d2b87c14c990c732b52e6abea907e4ef86166f (patch) | |
tree | 9ff01161129289fab06383b72300504ae2724f7b /requests_cache/__init__.py | |
parent | a70eea1beadcb2d555a7dac77738d0a21900703a (diff) | |
download | requests-cache-90d2b87c14c990c732b52e6abea907e4ef86166f.tar.gz |
Move misc minor utils to a separate module
Diffstat (limited to 'requests_cache/__init__.py')
-rw-r--r-- | requests_cache/__init__.py | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/requests_cache/__init__.py b/requests_cache/__init__.py index 2b53921..5f74a1f 100644 --- a/requests_cache/__init__.py +++ b/requests_cache/__init__.py @@ -1,44 +1,12 @@ # flake8: noqa: E402,F401 from logging import getLogger -from typing import Callable, Iterable, Dict -logger = getLogger(__name__) +logger = getLogger('requests_cache') # Version is defined in pyproject.toml. # It's copied here to make it easier for client code to check the installed version. __version__ = '0.9.0' - -def get_placeholder_class(original_exception: Exception = None): - """Create a placeholder type for a class that does not have dependencies installed. - This allows delaying ImportErrors until init time, rather than at import time. - """ - msg = 'Dependencies are not installed for this feature' - - def _log_error(): - logger.error(msg) - raise original_exception or ImportError(msg) - - class Placeholder: - def __init__(self, *args, **kwargs): - _log_error() - - def __getattr__(self, *args, **kwargs): - _log_error() - - def dumps(self, *args, **kwargs): - _log_error() - - return Placeholder - - -def get_valid_kwargs(func: Callable, kwargs: Dict, extras: Iterable[str] = None) -> Dict: - """Get the subset of non-None ``kwargs`` that are valid params for ``func``""" - params = list(signature(func).parameters) - params.extend(extras or []) - return {k: v for k, v in kwargs.items() if k in params and v is not None} - - try: from .backends import * from .cache_control import * |