Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 9, 2025
1 parent e4cf622 commit b90e934
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion surfactant/infoextractors/js_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def short_name() -> str:


@surfactant.plugin.hookimpl
def init_hook(command_name: Optional[str]=None):
def init_hook(command_name: Optional[str] = None):
"""Initialization hook to load the JavaScript library database."""
if command_name != "update-db": # Do not load the database if only updating the database.
logger.info("Initializing js_file...")
Expand Down
18 changes: 10 additions & 8 deletions surfactant/plugin/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#
# SPDX-License-Identifier: MIT
import sys
from typing import Any, List, Optional

import pluggy
from loguru import logger

from surfactant.configmanager import ConfigManager
from surfactant.plugin import hookspecs
from typing import List, Optional, Any


def _register_plugins(pm: pluggy.PluginManager) -> None:
Expand Down Expand Up @@ -148,14 +148,14 @@ def find_io_plugin(pm: pluggy.PluginManager, io_format: str, function_name: str)
:parampm (pluggy.PluginManager): The plugin manager instance.
:param io_format (str) : The name that the plugin is registered as.
:param function_name (str) : The name of the function
Returns:
Optional[Any]: The found plugin instance that matches the specified `io_format` and
implements the `function_name`, or `None` if no such plugin is found.
Optional[Any]: The found plugin instance that matches the specified `io_format` and
implements the `function_name`, or `None` if no such plugin is found.
If no plugin is found, an error is logged, and the program exits.
Raises:
SystemExit: If no plugin matching the criteria is found, the function logs an error message
SystemExit: If no plugin matching the criteria is found, the function logs an error message
and exits the program.
"""

Expand Down Expand Up @@ -213,13 +213,15 @@ def find_plugin_by_name(pm: pluggy.PluginManager, name: str) -> Optional[Any]:
return None


def call_init_hooks(pm: pluggy.PluginManager, hook_filter: List[str]=None, command_name: str=None) -> None:
def call_init_hooks(
pm: pluggy.PluginManager, hook_filter: List[str] = None, command_name: str = None
) -> None:
"""Call the initialization hook for plugins that implement it.
Args:
:param pm (pluggy.PluginManager): The plugin manager instance.
:param hook_filter (List[str]): A list of hook names to filter which plugins get initialized.
:param command_name (str): The name of the command invoking the initialization.
:param command_name (str): The name of the command invoking the initialization.
"""
for plugin in pm.get_plugins():
if is_hook_implemented(pm, plugin, "init_hook"):
Expand Down

0 comments on commit b90e934

Please sign in to comment.