Skip to content

Commit 53974e8

Browse files
[primer] Fall back to no rcfile rather than pylint's (#7798)
1 parent 7249be0 commit 53974e8

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

pylint/testutils/_primer/package_to_lint.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55
from __future__ import annotations
66

77
import logging
8+
import sys
89
from pathlib import Path
910

1011
from git.cmd import Git
1112
from git.repo import Repo
1213

14+
if sys.version_info >= (3, 8):
15+
from typing import Literal
16+
else:
17+
from typing_extensions import Literal
18+
1319
PRIMER_DIRECTORY_PATH = Path("tests") / ".pylint_primer_tests"
1420

1521

@@ -56,9 +62,10 @@ def __init__(
5662
self.minimum_python = minimum_python
5763

5864
@property
59-
def pylintrc(self) -> Path | None:
65+
def pylintrc(self) -> Path | Literal[""]:
6066
if self.pylintrc_relpath is None:
61-
return None
67+
# Fall back to "" to ensure pylint's own pylintrc is not discovered
68+
return ""
6269
return self.clone_directory / self.pylintrc_relpath
6370

6471
@property
@@ -75,9 +82,8 @@ def paths_to_lint(self) -> list[str]:
7582
@property
7683
def pylint_args(self) -> list[str]:
7784
options: list[str] = []
78-
if self.pylintrc is not None:
79-
# There is an error if rcfile is given but does not exist
80-
options += [f"--rcfile={self.pylintrc}"]
85+
# There is an error if rcfile is given but does not exist
86+
options += [f"--rcfile={self.pylintrc}"]
8187
return self.paths_to_lint + options + self.pylint_additional_args
8288

8389
def lazy_clone(self) -> str: # pragma: no cover

tests/testutils/_primer/test_package_to_lint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def test_package_to_lint_default_value() -> None:
4242
branch="main",
4343
directories=["src/flask"], # Must work on Windows (src\\flask)
4444
)
45-
assert package_to_lint.pylintrc is None
45+
assert package_to_lint.pylintrc == ""
4646
expected_path_to_lint = (
4747
PRIMER_DIRECTORY_PATH / "pallets" / "flask" / "src" / "flask"
4848
)
49-
assert package_to_lint.pylint_args == [str(expected_path_to_lint)]
49+
assert package_to_lint.pylint_args == [str(expected_path_to_lint), "--rcfile="]

0 commit comments

Comments
 (0)