From 24df36e49f5f0975bd6f5da04ab7a7f7010c4262 Mon Sep 17 00:00:00 2001 From: V1SHAL421 Date: Sun, 1 Mar 2026 18:46:53 +0000 Subject: [PATCH 1/3] Fix: allow pytest.HIDDEN_PARAM in ids argument of mark.parametrize (#14234) --- src/_pytest/mark/structures.py | 2 +- testing/typing_checks.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 0fa6e8babba..f70a655ce72 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -532,7 +532,7 @@ def __call__( argvalues: Collection[ParameterSet | Sequence[object] | object], *, indirect: bool | Sequence[str] = ..., - ids: Iterable[None | str | float | int | bool] + ids: Iterable[None | str | float | int | bool | _HiddenParam] | Callable[[Any], object | None] | None = ..., scope: _ScopeName | None = ..., diff --git a/testing/typing_checks.py b/testing/typing_checks.py index ff1c0e60cd9..942243420a9 100644 --- a/testing/typing_checks.py +++ b/testing/typing_checks.py @@ -60,6 +60,12 @@ def check_testreport_attributes(report: TestReport) -> None: assert_type(report.location, tuple[str, int | None, str]) +# Issue #14234. +@pytest.mark.parametrize("x", [1, 2], ids=[pytest.HIDDEN_PARAM, "visible"]) +def test_hidden_param(x: int) -> None: + pass + + # Test @pytest.mark.parametrize iterator argvalues deprecation. # Will be complain about unused type ignore if doesn't work. @pytest.mark.parametrize("x", iter(range(10))) # type: ignore[deprecated] From d86e0054486605fb33ef9cd1ec4e866b032f3df2 Mon Sep 17 00:00:00 2001 From: V1SHAL421 Date: Sun, 1 Mar 2026 20:33:37 +0000 Subject: [PATCH 2/3] Add changelog fragment for #14234 --- changelog/14234.improvement.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/14234.improvement.rst diff --git a/changelog/14234.improvement.rst b/changelog/14234.improvement.rst new file mode 100644 index 00000000000..500f81cc72a --- /dev/null +++ b/changelog/14234.improvement.rst @@ -0,0 +1 @@ +Allow ``pytest.HIDDEN_PARAM`` in ``parametrize(ids=...)`` type annotations. \ No newline at end of file From 2ee52998b76ef2ce3ffc0abe5ff4813e077785e4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Mar 2026 20:35:15 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- changelog/14234.improvement.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/14234.improvement.rst b/changelog/14234.improvement.rst index 500f81cc72a..9d102256969 100644 --- a/changelog/14234.improvement.rst +++ b/changelog/14234.improvement.rst @@ -1 +1 @@ -Allow ``pytest.HIDDEN_PARAM`` in ``parametrize(ids=...)`` type annotations. \ No newline at end of file +Allow ``pytest.HIDDEN_PARAM`` in ``parametrize(ids=...)`` type annotations.