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 Jun 10, 2024
1 parent 7aca3c8 commit 5646d29
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
4 changes: 1 addition & 3 deletions pylint/lint/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ def check_parallel(
# The linter is inherited by all the pool's workers, i.e. the linter
# is identical to the linter object here. This is required so that
# a custom PyLinter object can be used.
initializer = functools.partial(
_worker_initialize, extra_sys_paths=extra_sys_paths
)
initializer = functools.partial(_worker_initialize, extra_sys_paths=extra_sys_paths)
with ProcessPoolExecutor(
max_workers=jobs, initializer=initializer, initargs=(dill.dumps(linter),)
) as executor:
Expand Down
15 changes: 8 additions & 7 deletions pylint/lint/pylinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
from pylint.lint.utils import (
_is_relative_to,
augmented_sys_path,
realpath_transformer,
get_fatal_error_message,
prepare_crash_report,
realpath_transformer,
)
from pylint.message import Message, MessageDefinition, MessageDefinitionStore
from pylint.reporters.base_reporter import BaseReporter
Expand All @@ -75,8 +75,7 @@
class GetAstProtocol(Protocol):
def __call__(
self, filepath: str, modname: str, data: str | None = None
) -> nodes.Module:
...
) -> nodes.Module: ...


def _read_stdin() -> str:
Expand Down Expand Up @@ -310,9 +309,9 @@ def __init__(
"""Dictionary of possible but non-initialized reporters."""

# Attributes for checkers and plugins
self._checkers: defaultdict[
str, list[checkers.BaseChecker]
] = collections.defaultdict(list)
self._checkers: defaultdict[str, list[checkers.BaseChecker]] = (
collections.defaultdict(list)
)
"""Dictionary of registered and initialized checkers."""
self._dynamic_plugins: dict[str, ModuleType | ModuleNotFoundError | bool] = {}
"""Set of loaded plugin names."""
Expand Down Expand Up @@ -674,7 +673,9 @@ def check(self, files_or_modules: Sequence[str]) -> None:
}
)
# Prefer package paths detected per module over user-defined PYTHONPATH additions
extra_sys_paths = extra_packages_paths + realpath_transformer(self.config.pythonpath)
extra_sys_paths = extra_packages_paths + realpath_transformer(
self.config.pythonpath
)

# TODO: Move the parallel invocation into step 3 of the checking process
if not self.config.from_stdin and self.config.jobs > 1:
Expand Down
4 changes: 3 additions & 1 deletion pylint/pyreverse/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ def run(self, args: list[str]) -> int:
{discover_package_path(arg, self.config.source_roots) for arg in args}
)
# Prefer package paths detected per module over global PYTHONPATH additons

Check notice on line 307 in pylint/pyreverse/main.py

View workflow job for this annotation

GitHub Actions / pylint

C0401

Wrong spelling of a word 'additons' in a comment:
extra_sys_paths = extra_packages_paths + realpath_transformer(self.config.pythonpath)
extra_sys_paths = extra_packages_paths + realpath_transformer(
self.config.pythonpath
)
with augmented_sys_path(extra_sys_paths):
project = project_from_files(
args,
Expand Down
4 changes: 3 additions & 1 deletion tests/lint/unittest_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,9 @@ def test_import_sibling_module_from_namespace(initialized_linter: PyLinter) -> N
assert not linter.stats.by_msg


def test_import_external_module_with_relative_pythonpath_config(initialized_linter: PyLinter) -> None:
def test_import_external_module_with_relative_pythonpath_config(
initialized_linter: PyLinter,
) -> None:
"""Given a module that imports an external module, ensure that the external module
is found when the path to the external module is configured in `main.pythonpath`.
Expand Down
4 changes: 1 addition & 3 deletions tests/test_check_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ def test_worker_initialize(self) -> None:
def test_worker_initialize_with_package_paths(self) -> None:
linter = PyLinter(reporter=Reporter())
with augmented_sys_path([]):
worker_initialize(
linter=dill.dumps(linter), extra_sys_paths=["fake-path"]
)
worker_initialize(linter=dill.dumps(linter), extra_sys_paths=["fake-path"])
assert "fake-path" in sys.path

def test_worker_initialize_reregisters_custom_plugins(self) -> None:
Expand Down

0 comments on commit 5646d29

Please sign in to comment.