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

Add import caches #21

Merged
merged 1 commit into from
Aug 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/pl_devtools/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
# limitations under the License.
import importlib
import operator
from functools import lru_cache
from importlib.util import find_spec
from typing import Callable

import pkg_resources
from packaging.version import Version


@lru_cache()
def package_available(package_name: str) -> bool:
"""Check if a package is available in your environment.

Expand All @@ -34,6 +36,7 @@ def package_available(package_name: str) -> bool:
return False


@lru_cache()
def module_available(module_path: str) -> bool:
"""Check if a module path is available in your environment.

Expand Down