Skip to content
Open
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
8 changes: 5 additions & 3 deletions xarray/namedarray/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@


@lru_cache
def module_available(module: str, minversion: str | None = None) -> bool:
def module_available(module: str | None, minversion: str | None = None) -> bool:
"""Checks whether a module is installed without importing it.

Use this for a lightweight check and lazy imports.

Parameters
----------
module : str
Name of the module.
module : str or None
Name of the module. If None, returns False.
minversion : str, optional
Minimum version of the module

Expand All @@ -54,6 +54,8 @@ def module_available(module: str, minversion: str | None = None) -> bool:
available : bool
Whether the module is installed.
"""
if module is None:
return False
if importlib.util.find_spec(module) is None:
return False

Expand Down
Loading