Skip to content

Commit

Permalink
Ensure decorators always receive strict=True
Browse files Browse the repository at this point in the history
  • Loading branch information
LightArrowsEXE committed Aug 18, 2024
1 parent 2462ac0 commit e8de31c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions lvsfunc/dependency/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def check_installed_packages(

def required_packages(
plugins: list[str] | dict[str, DEP_URL] = [],
strict: bool = True,
func_except: FuncExceptT | None = None
) -> Callable[[F], F]:
"""
Expand All @@ -85,16 +84,14 @@ def required_packages(
:param packages: A list of packages to check for. If a dict is passed,
the values are treated as either a URL or a pip command to download the package.
:param strict: If True, raises an error if any of the packages are missing.
Default: True.
:param func_except: Function returned for custom error handling.
This should only be set by VS package developers.
"""

def decorator(func: F) -> F:
@wraps(func)
def wrapper(*args: Any, **kwargs: Any) -> Any:
check_installed_packages(plugins, strict, func_except or required_packages)
check_installed_packages(plugins, True, func_except or required_packages)

return func(*args, **kwargs)

Expand Down
5 changes: 1 addition & 4 deletions lvsfunc/dependency/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def check_installed_plugins(

def required_plugins(
plugins: list[str] | dict[str, DEP_URL] = [],
strict: bool = True,
func_except: FuncExceptT | None = None
) -> Callable[[F], F]:
"""
Expand All @@ -81,16 +80,14 @@ def required_plugins(
:param plugins: A list of plugins to check for. If a dict is passed,
the values are treated as URLs to download the plugin.
:param strict: If True, raises an error if any of the plugins are missing.
Default: True.
:param func_except: Function returned for custom error handling.
This should only be set by VS package developers.
"""

def decorator(func: F) -> F:
@wraps(func)
def wrapper(*args: Any, **kwargs: Any) -> Any:
check_installed_plugins(plugins, strict, func_except or required_plugins)
check_installed_plugins(plugins, True, func_except or required_plugins)

return func(*args, **kwargs)

Expand Down

0 comments on commit e8de31c

Please sign in to comment.