Skip to content

Make Metafunc.parametrize keyword-only from indirect onwards#14753

Merged
Zac-HD merged 3 commits into
pytest-dev:mainfrom
Zac-HD:claude/parametrize-keyword-only
Jul 22, 2026
Merged

Make Metafunc.parametrize keyword-only from indirect onwards#14753
Zac-HD merged 3 commits into
pytest-dev:mainfrom
Zac-HD:claude/parametrize-keyword-only

Conversation

@Zac-HD

@Zac-HD Zac-HD commented Jul 21, 2026

Copy link
Copy Markdown
Member

Passing indirect/ids/scope positionally was a common source of confusing errors -- most notably parametrize("arg1", "arg2", [(1, 2)]) sending the argvalues into indirect and failing with "indirect fixture '(1, 2)' doesn't exist" (closes #8593).

The type annotations for the pytest.mark.parametrize stub have declared these arguments keyword-only all along; this aligns the runtime signature.

Technically a breaking change, but I think the overwhelmingly common case is that it was a confusing error, not a deliberate positional use.

Passing indirect/ids/scope positionally was a common source of
confusing errors -- most notably parametrize("arg1", "arg2", [(1, 2)])
sending the argvalues into indirect and failing with "indirect fixture
'(1, 2)' doesn't exist" (pytest-dev#8593). The type annotations for the
pytest.mark.parametrize stub have declared these arguments keyword-only
all along; this aligns the runtime signature.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018RzGTXa8VxHtYauuhN51Mv
@Zac-HD
Zac-HD requested a review from RonnyPfannschmidt July 21, 2026 21:06
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jul 21, 2026
claude added 2 commits July 21, 2026 21:09
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018RzGTXa8VxHtYauuhN51Mv

@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.

might want to do a grep.app search as community service - there mgiht be missed breaks for downstreams

@Zac-HD

Zac-HD commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

I had Claude run some scans of the ecosystem:

1. PyPI top-5000 AST scan. Downloaded the sdist of each of the top 5000 packages by downloads. 4,905 packages scanned successfully (564,808 Python files), containing 135,419 parametrize calls. Zero would break.

2. GitHub-wide AST sample. Via Sourcegraph's search API, fetched 467 complete files across 140 repos matching pytest.mark.parametrize( and ran the same AST analysis: 1,439 calls, zero breaking.

3. GitHub-wide regex counts. Against a baseline of ~1.57M pytest.mark.parametrize( matches on Sourcegraph, precision-first regex patterns found: positional bool 4–9, string 3, list 2–3, identifier ≤9 — 10–25 affected call sites, of which half are errors.

Given the benefits to new users, I'm comfortable merging.

@Zac-HD
Zac-HD merged commit a56281b into pytest-dev:main Jul 22, 2026
36 checks passed
@Zac-HD
Zac-HD deleted the claude/parametrize-keyword-only branch July 22, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error output when specifying multiple argument strings with parametrize

3 participants