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 Sep 25, 2024
1 parent 679f1f2 commit 648b52c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
3 changes: 1 addition & 2 deletions pylint/lint/expand_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from collections.abc import Sequence
from pathlib import Path
from re import Pattern
from typing import cast

from astroid import modutils

Expand Down Expand Up @@ -37,7 +36,7 @@ def discover_package_path(
for source_root in source_roots:
source_root = os.path.realpath(os.path.expanduser(source_root))
if os.path.commonpath([source_root, dirname]) == source_root:
#return cast(Sequence[str], [source_root])
# return cast(Sequence[str], [source_root])
return [source_root]

if len(source_roots) != 0:
Expand Down
7 changes: 5 additions & 2 deletions pylint/lint/pylinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,11 @@ def check(self, files_or_modules: Sequence[str]) -> None:
extra_packages_paths = list(
dict.fromkeys(
[
path for file_or_module in files_or_modules
for path in discover_package_path(file_or_module, self.config.source_roots)
path
for file_or_module in files_or_modules
for path in discover_package_path(
file_or_module, self.config.source_roots
)
]
).keys()
)
Expand Down
7 changes: 5 additions & 2 deletions pylint/pyreverse/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,11 @@ def run(self, args: list[str]) -> int:
print(self.help())
return 1
extra_packages_paths = list(
{path for arg in args
for path in discover_package_path(arg, self.config.source_roots)}
{
path
for arg in args
for path in discover_package_path(arg, self.config.source_roots)
}
)
with augmented_sys_path(extra_packages_paths):
project = project_from_files(
Expand Down
9 changes: 6 additions & 3 deletions tests/lint/unittest_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ def test_one_arg(fake_path: list[str], case: list[str]) -> None:
expected = [join(chroot, "a"), *fake_path]

extra_sys_paths = [
path for arg in case
path
for arg in case
for path in expand_modules.discover_package_path(arg, [])
]

Expand All @@ -158,7 +159,8 @@ def test_two_similar_args(fake_path: list[str], case: list[str]) -> None:
expected = [join(chroot, "a"), *fake_path]

extra_sys_paths = [
path for arg in case
path
for arg in case
for path in expand_modules.discover_package_path(arg, [])
]

Expand All @@ -185,7 +187,8 @@ def test_more_args(fake_path: list[str], case: list[str]) -> None:
] + fake_path

extra_sys_paths = [
path for arg in case
path
for arg in case
for path in expand_modules.discover_package_path(arg, [])
]

Expand Down

0 comments on commit 648b52c

Please sign in to comment.