Skip to content

Commit faac7cd

Browse files
committed
Fix a bunch of ruff errors
1 parent eacfaf8 commit faac7cd

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

pip_check_reqs/common.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
"""Common functions."""
32

43
from __future__ import annotations
@@ -52,15 +51,15 @@ def set_location(self, location: str) -> None:
5251
self._location = location
5352

5453
# Ignore the name error as we are overriding the method.
55-
def visit_Import( # pylint: disable=invalid-name
54+
def visit_Import( # noqa: N802, pylint: disable=invalid-name
5655
self,
5756
node: ast.Import,
5857
) -> None:
5958
for alias in node.names:
6059
self._add_module(alias.name, node.lineno)
6160

6261
# Ignore the name error as we are overriding the method.
63-
def visit_ImportFrom( # pylint: disable=invalid-name
62+
def visit_ImportFrom( # noqa: N802, pylint: disable=invalid-name
6463
self,
6564
node: ast.ImportFrom,
6665
) -> None:
@@ -145,7 +144,6 @@ def find_imported_modules(
145144
continue
146145
log.debug("scanning: %s", os.path.relpath(filename))
147146
content = filename.read_text(encoding="utf-8")
148-
# with open(filename, encoding="utf-8") as file_obj:
149147
vis.set_location(str(filename))
150148
vis.visit(ast.parse(content, str(filename)))
151149
return vis.finalise()
@@ -154,14 +152,16 @@ def find_imported_modules(
154152
def find_required_modules(
155153
*,
156154
ignore_requirements_function: Callable[
157-
[str | ParsedRequirement], bool,
155+
[str | ParsedRequirement],
156+
bool,
158157
],
159158
skip_incompatible: bool,
160159
requirements_filename: Path,
161160
) -> set[NormalizedName]:
162161
explicit = set()
163162
for requirement in parse_requirements(
164-
str(requirements_filename), session=PipSession(),
163+
str(requirements_filename),
164+
session=PipSession(),
165165
):
166166
requirement_name = install_req_from_line(
167167
requirement.requirement,

pip_check_reqs/find_extra_reqs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def find_extra_reqs(
3131
ignore_files_function: Callable[[str], bool],
3232
ignore_modules_function: Callable[[str], bool],
3333
ignore_requirements_function: Callable[
34-
[str | ParsedRequirement], bool,
34+
[str | ParsedRequirement],
35+
bool,
3536
],
3637
skip_incompatible: bool,
3738
) -> list[str]:
@@ -73,7 +74,9 @@ def find_extra_reqs(
7374
package_files.append(str(relative_item_location))
7475

7576
log.debug(
76-
"installed package: %s (at %s)", package_name, package_location,
77+
"installed package: %s (at %s)",
78+
package_name,
79+
package_location,
7780
)
7881
for package_file in package_files:
7982
path = os.path.realpath(

pip_check_reqs/find_missing_reqs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ def find_missing_reqs(
6868
package_files.append(str(relative_item_location))
6969

7070
log.debug(
71-
"installed package: %s (at %s)", package_name, package_location,
71+
"installed package: %s (at %s)",
72+
package_name,
73+
package_location,
7274
)
7375
for package_file in package_files:
7476
path = os.path.realpath(

spelling_private_dict.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
pragma
2+
reqs
3+

tests/test_common.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_found_module() -> None:
3434
found_module = common.FoundModule("spam", "ham")
3535
assert found_module.modname == "spam"
3636
assert found_module.filename == str(Path("ham").resolve())
37-
assert found_module.locations == []
37+
assert not found_module.locations
3838

3939

4040
@pytest.mark.parametrize(
@@ -51,7 +51,7 @@ def test_found_module() -> None:
5151
],
5252
)
5353
def test_import_visitor(stmt: str, result: list[str]) -> None:
54-
vis = common._ImportVisitor( # pylint: disable=protected-access
54+
vis = common._ImportVisitor( # noqa: SLF001,E501, pylint: disable=protected-access
5555
ignore_modules_function=common.ignorer(ignore_cfg=[]),
5656
)
5757
vis.set_location("spam.py")
@@ -188,6 +188,7 @@ def ignore_mods(module: str) -> bool:
188188
],
189189
)
190190
def test_ignorer(
191+
*,
191192
monkeypatch: pytest.MonkeyPatch,
192193
ignore_cfg: list[str],
193194
candidate: str,

0 commit comments

Comments
 (0)