Skip to content

[ruff] Apply safe autofixes from ruff 0.16 - #14897

Merged
Pierre-Sassoulas merged 5 commits into
pytest-dev:mainfrom
Pierre-Sassoulas:ruff-safe-autofixes
Aug 19, 2026
Merged

[ruff] Apply safe autofixes from ruff 0.16#14897
Pierre-Sassoulas merged 5 commits into
pytest-dev:mainfrom
Pierre-Sassoulas:ruff-safe-autofixes

Conversation

@Pierre-Sassoulas

Copy link
Copy Markdown
Member

Continuing after #14895, this enable the rule that have safe autofixes.

@Pierre-Sassoulas Pierre-Sassoulas added the skip news used on prs to opt out of the changelog requirement label Aug 17, 2026
Comment thread src/_pytest/unittest.py Outdated
teardown = getattr(cls, "tearDownClass", None)
if setup is None and teardown is None:
return None
return

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line isn't covered by tests because unittest.TestCase defines both setUpClass and tearDownClass as classmethods so it cannot be reached afaiu.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log a followup issue about removing this based on supported versions?

@Pierre-Sassoulas Pierre-Sassoulas Aug 19, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked it up, unittest.TestCase has carried default no-op setUpClass/tearDownClass classmethods since Python 3.2 (https://docs.python.org/3/library/unittest.html#unittest.TestCase.setUpClass / python/cpython@847a4110ea99). PyPy takes unittest verbatim from CPython's pure-Python stdlib. This line was introduced in pytest in a616adf probably taken from 0f918b1 that was more generic (handle pytest struct too ?)

@Pierre-Sassoulas

Copy link
Copy Markdown
Member Author

It seems I can't merge if codecov is not 100%. I only have the enable auto-merge button and no way to bypass. (Change in github's UI? Also happens in pylint and I didn't touch anything) I'll do the follow-up PR as a prior PR then.

Pierre-Sassoulas and others added 5 commits August 19, 2026 11:11
Both functions return nothing anywhere else, so a bare 'return' says it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two modules kept an 'if TYPE_CHECKING: pass' block and the import that
went with it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
'Decimal("1")' and 'Decimal(1)' build the same value, the int form skips
the string parsing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Eight hand-rolled 'startswith' + slice pairs become the dedicated string
methods.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Nine '"a b c".split()' calls become plain list literals.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Pierre-Sassoulas
Pierre-Sassoulas merged commit d89ac92 into pytest-dev:main Aug 19, 2026
36 checks passed
@Pierre-Sassoulas
Pierre-Sassoulas deleted the ruff-safe-autofixes branch August 19, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news used on prs to opt out of the changelog requirement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants