diff options
author | Jacob Walls <jacobtylerwalls@gmail.com> | 2022-11-19 08:42:09 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-19 14:42:09 +0100 |
commit | 53974e8e6711cec3e5659c26855cec6fada5a9cf (patch) | |
tree | b7aacfbeaafd1241292bc059193b60d868854b29 | |
parent | 7249be08c68118091ce30967f4b4cea75b2e0e5c (diff) | |
download | pylint-git-53974e8e6711cec3e5659c26855cec6fada5a9cf.tar.gz |
[primer] Fall back to no rcfile rather than pylint's (#7798)
-rw-r--r-- | pylint/testutils/_primer/package_to_lint.py | 16 | ||||
-rw-r--r-- | tests/testutils/_primer/test_package_to_lint.py | 4 |
2 files changed, 13 insertions, 7 deletions
diff --git a/pylint/testutils/_primer/package_to_lint.py b/pylint/testutils/_primer/package_to_lint.py index c472a98c5..09ecb4456 100644 --- a/pylint/testutils/_primer/package_to_lint.py +++ b/pylint/testutils/_primer/package_to_lint.py @@ -5,11 +5,17 @@ from __future__ import annotations import logging +import sys from pathlib import Path from git.cmd import Git from git.repo import Repo +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + PRIMER_DIRECTORY_PATH = Path("tests") / ".pylint_primer_tests" @@ -56,9 +62,10 @@ class PackageToLint: self.minimum_python = minimum_python @property - def pylintrc(self) -> Path | None: + def pylintrc(self) -> Path | Literal[""]: if self.pylintrc_relpath is None: - return None + # Fall back to "" to ensure pylint's own pylintrc is not discovered + return "" return self.clone_directory / self.pylintrc_relpath @property @@ -75,9 +82,8 @@ class PackageToLint: @property def pylint_args(self) -> list[str]: options: list[str] = [] - if self.pylintrc is not None: - # There is an error if rcfile is given but does not exist - options += [f"--rcfile={self.pylintrc}"] + # There is an error if rcfile is given but does not exist + options += [f"--rcfile={self.pylintrc}"] return self.paths_to_lint + options + self.pylint_additional_args def lazy_clone(self) -> str: # pragma: no cover diff --git a/tests/testutils/_primer/test_package_to_lint.py b/tests/testutils/_primer/test_package_to_lint.py index 2ee9f3dec..220e2c0b2 100644 --- a/tests/testutils/_primer/test_package_to_lint.py +++ b/tests/testutils/_primer/test_package_to_lint.py @@ -42,8 +42,8 @@ def test_package_to_lint_default_value() -> None: branch="main", directories=["src/flask"], # Must work on Windows (src\\flask) ) - assert package_to_lint.pylintrc is None + assert package_to_lint.pylintrc == "" expected_path_to_lint = ( PRIMER_DIRECTORY_PATH / "pallets" / "flask" / "src" / "flask" ) - assert package_to_lint.pylint_args == [str(expected_path_to_lint)] + assert package_to_lint.pylint_args == [str(expected_path_to_lint), "--rcfile="] |