Skip to content

Include pytest.HIDDEN_PARAM in parametrize(ids=...) type annotations#14246

Merged
bluetech merged 1 commit intopytest-dev:mainfrom
V1SHAL421:typing-allow-hidden-param-ids
Apr 26, 2026
Merged

Include pytest.HIDDEN_PARAM in parametrize(ids=...) type annotations#14246
bluetech merged 1 commit intopytest-dev:mainfrom
V1SHAL421:typing-allow-hidden-param-ids

Conversation

@V1SHAL421
Copy link
Copy Markdown
Contributor

Summary

Closes #14234

The ids keyword argument of pytest.mark.parametrize did not allow pytest.HIDDEN_PARAM, unlike pytest.mark.param(id=...).

Problem

The following produced a typing error:

import pytest

@pytest.mark.parametrize(
    "x",
    [1, 2, 3],
    ids=[pytest.HIDDEN_PARAM, "two", "three"],
)
def test_example(x: int) -> None:
    pass

Solution

Modified _ParametrizeMarkDecorator.__call__()'s ids argument to include the _HiddenParam enum.

Test Cases

Type check for passing pytest.HIDDEN_PARAM in the ids argument for pytest.mark.parametrize

@pytest.mark.parametrize("x", [1, 2], ids=[pytest.HIDDEN_PARAM, "visible"])
def test_hidden_param(x: int) -> None:
    pass

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Mar 1, 2026
@bluetech bluetech force-pushed the typing-allow-hidden-param-ids branch from bf98d44 to 560b678 Compare April 26, 2026 07:47
Copy link
Copy Markdown
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Thanks, we missed this.

@bluetech bluetech enabled auto-merge April 26, 2026 07:49
@bluetech bluetech merged commit a95bea7 into pytest-dev:main Apr 26, 2026
33 checks passed
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.

Type annotation for parametrize ids should allow HIDDEN_PARAM

2 participants