Merge pull request #11961 Add some autofixable refactor rules from pylint
This commit is contained in:
commit
526b971221
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue