Skip to content

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

Open
V1SHAL421 wants to merge 3 commits intopytest-dev:mainfrom
V1SHAL421:typing-allow-hidden-param-ids
Open

Include pytest.HIDDEN_PARAM in parametrize(ids=...) type annotations#14246
V1SHAL421 wants to merge 3 commits intopytest-dev:mainfrom
V1SHAL421:typing-allow-hidden-param-ids

Conversation

@V1SHAL421
Copy link

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

1 participant