Skip to content

Commit

Permalink
optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Jul 12, 2023
1 parent 4ecf896 commit 8716afc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lightning_utilities/core/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ class RequirementCache:
False
"""

def __init__(self, requirement: str, module: Optional[str] = None) -> None:
def __init__(self, requirement: Optional[str] = None, module: Optional[str] = None) -> None:
if not (requirement or module):
raise ValueError("At least one arguments need to be set.")
self.requirement = requirement
self.module = module

Expand Down Expand Up @@ -290,7 +292,7 @@ def requires(*module_path_version: str, raise_exception: bool = True) -> Callabl

def decorator(func: Callable[P, T]) -> Callable[P, T]:
reqs = [
ModuleAvailableCache(mod_ver) if "." in mod_ver else RequirementCache(mod_ver)
RequirementCache(module=mod_ver) if "." in mod_ver else RequirementCache(requirement=mod_ver)
for mod_ver in module_path_version
]
available = all(map(bool, reqs))
Expand Down

0 comments on commit 8716afc

Please sign in to comment.