diff --git a/pyproject.toml b/pyproject.toml index 0a83df1bb..72988e233 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,6 +104,9 @@ select = [ "W", # pycodestyle "PIE", # flake8-pie "PGH004", # pygrep-hooks - Use specific rule codes when using noqa + "PLE", # pylint error + "PLW", # pylint warning + "PLR1714", # Consider merging multiple comparisons ] ignore = [ # bugbear ignore @@ -135,6 +138,11 @@ ignore = [ "D415", # First line should end with a period, question mark, or exclamation point # ruff ignore "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` + # pylint ignore + "PLW0603", # Using the global statement + "PLW0120", # remove the else and dedent its contents + "PLW2901", # for loop variable overwritten by assignment target + "PLR5501", # Use `elif` instead of `else` then `if` ] [tool.ruff.lint.pycodestyle] diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 400b38642..077fa65da 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -289,7 +289,7 @@ def get_user_id() -> int | None: # mypy follows the version and platform checking expectation of PEP 484: # https://mypy.readthedocs.io/en/stable/common_issues.html?highlight=platform#python-version-and-system-platform-checks # Containment checks are too complex for mypy v1.5.0 and cause failure. - if sys.platform == "win32" or sys.platform == "emscripten": + if sys.platform in {"win32", "emscripten"}: # win32 does not have a getuid() function. # Emscripten has a return 0 stub. return None diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index 51becf97b..4ca356f31 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -624,7 +624,7 @@ class LogXML: def update_testcase_duration(self, report: TestReport) -> None: """Accumulate total duration for nodeid from given report and update the Junit.testcase with the new total if already created.""" - if self.report_duration == "total" or report.when == self.report_duration: + if self.report_duration in {"total", report.when}: reporter = self.node_reporter(report) reporter.duration += getattr(report, "duration", 0.0) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 10ca00890..91c48540d 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1786,11 +1786,10 @@ class Function(PyobjMixin, nodes.Item): if len(ntraceback) > 2: ntraceback = Traceback( ( - entry - if i == 0 or i == len(ntraceback) - 1 - else entry.with_repr_style("short") + ntraceback[0], + *(t.with_repr_style("short") for t in ntraceback[1:-1]), + ntraceback[-1], ) - for i, entry in enumerate(ntraceback) ) return ntraceback diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 62dafe703..8909d95ef 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -381,7 +381,7 @@ class TerminalReporter: if self.config.getoption("setupshow", False): return False cfg: str = self.config.getini("console_output_style") - if cfg == "progress" or cfg == "progress-even-when-capture-no": + if cfg in {"progress", "progress-even-when-capture-no"}: return "progress" elif cfg == "count": return "count" diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index b045b601e..e676d562c 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -429,7 +429,7 @@ class TestAssertionRewrite: def f2() -> None: x = 1 - assert x == 1 or x == 2 + assert x == 1 or x == 2 # noqa: PLR1714 getmsg(f2, must_pass=True)