close
Skip to content

[ruff] Apply unsafe autofixes from ruff 0.16 - #14913

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

[ruff] Apply unsafe autofixes from ruff 0.16#14913
Pierre-Sassoulas merged 8 commits into
pytest-dev:mainfrom
Pierre-Sassoulas:ruff-unsafe-autofixes

Conversation

@Pierre-Sassoulas

Copy link
Copy Markdown
Member

Follow-up to #14897 and #14895, now the unsafe autofix. (Verified by me)

Pierre-Sassoulas and others added 7 commits August 19, 2026 14:23
One 'list(<genexp>)' in Source.__init__ becomes a list comprehension.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The 'list([0, 2])' in test_assertion.py is already a list, the outer call
adds nothing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
'sorted()' already consumes any iterable, the inner 'list()' is dead weight.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
'merge_family' never uses the key of the right hand family, iterate over
'.values()' instead of '.items()'.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
'_get_assertion_exprs' guard becomes 'bool(util._assertion_pass)'.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Both 'map(lambda ...)' calls become generator expressions.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Iterating a dict already yields its keys.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Pierre-Sassoulas Pierre-Sassoulas added the skip news used on prs to opt out of the changelog requirement label Aug 19, 2026

@RonnyPfannschmidt RonnyPfannschmidt left a comment

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.

Lovely

Comment thread src/_pytest/config/__init__.py Outdated
elif type == "linelist":
if isinstance(value, str):
return [t for t in map(lambda x: x.strip(), value.split("\n")) if t]
return [t for t in (x.strip() for x in value.split("\n")) if t]

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.

Suggested change
return [t for t in (x.strip() for x in value.split("\n")) if t]
return [xs for x in value.split("\n")) if (xs := x.strip()]

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 kid you not I considered to do that, I rewrote my branch for it and then reverted and rewrote again :D

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.

Took the old commit with 'stripped' let me know if you prefer the short variable name

The C417 fix in the previous commit is what ruff generates, and it leaves a
generator nested inside a comprehension that then filters it. Binding the
stripped line once says the same thing in one pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@RonnyPfannschmidt RonnyPfannschmidt left a comment

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.

lovely, lets keep the long word
thanks !

@Pierre-Sassoulas
Pierre-Sassoulas merged commit efa117a into pytest-dev:main Aug 19, 2026
36 checks passed
@Pierre-Sassoulas
Pierre-Sassoulas deleted the ruff-unsafe-autofixes branch August 19, 2026 19:36
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.

2 participants