Skip to content

Type checking pytest.param #197

Closed as not planned
Closed as not planned
@jamesbraza

Description

@jamesbraza

Imagine I have some code like this:

import pytest


@pytest.mark.parametrize(
    "arg",
    [
        pytest.param("1", id="good"),
        pytest.param(2, id="bad"),
    ],
)
def test_arg(arg: str) -> None:
    assert arg

Currently with Python 3.11, mypy==1.16.0 and pytest-mypy==1.0.1 won't flag that the second pytest.param actually has a type mismatch (int vs str).

It would be super useful to flag this as a latent TypeError when using pytest --mypy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions