Skip to main content

Build Status PyPI

mypy-pytest-parametrize

Check pytest.mark.parametrize and karva.tags.parametrize values against test annotations.

For example, this plugin reports the float passed to a parameter annotated as int:

"""Showcase errors in pytest parametrized values."""

import pytest


@pytest.mark.parametrize(
    argnames="arg",
    argvalues=[
        123,
        456.789,  # type: ignore[pytest-parametrize]
    ],
)
def test_foo(arg: int) -> None:
    """Check a parametrized integer."""
    assert arg > 0

Why?

pytest accepts parametrized values without checking them against the test’s annotations. This plugin lets mypy find incompatible values before the tests run. It supports multiple parameters, stacked decorators, and inline pytest.param calls.

Installation

pip install mypy-pytest-parametrize

Configure mypy to use the plugin

Add the plugin to your mypy configuration file:

pyproject.toml:

[tool.mypy]

plugins = [
    "mypy_pytest_parametrize",
]

mypy.ini, .mypy.ini, or setup.cfg:

[mypy]
plugins = mypy_pytest_parametrize

Karva

The same plugin configuration checks Karva tests using @karva.tags.parametrize. It supports Karva’s arg_names and arg_values keywords, stacked tags, and inline karva.param calls with IDs or tags. Karva must be installed in the environment where mypy runs.

For a single parameter, Karva treats each row as the parameter’s value even when the name is supplied as a list or tuple. For example, @karva.tags.parametrize(["value"], [(1, "x")]) supplies a tuple[int, str] to value.

Karva diagnostics use the existing pytest-parametrize error code.

Indirect fixtures and static limits

indirect=True is excluded because its values are fixture inputs, rather than the values received by the test. With indirect=["fixture_name"], the other parameters are still checked.

Parameter names and fixture routing determined at runtime are not checked. Stored decorator objects and class-level parametrization are also excluded. Stored pytest.param and karva.param objects and starred values within a row are also skipped when their individual types are unavailable. Values typed as Any retain mypy’s usual behavior.

The plugin follows the proposal in pytest issue #9334.

Metadata

Release files for mypy-pytest-parametrize 2026.10.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mypy-pytest-parametrize 2026.10.5.1
File Size Uploaded
mypy_pytest_parametrize-2026.10.5.1.tar.gz 29.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mypy-pytest-parametrize 2026.10.5.1
File Interpreter ABI Platform
mypy_pytest_parametrize-2026.10.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.5 kB

Release files / mypy_pytest_parametrize-2026.10.5.1.tar.gz

Download URL mypy_pytest_parametrize-2026.10.5.1.tar.gz
Size 29.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c8b2ec94c216260ee3b1bf942574b9e5e7f1960245418fe491bf658b9acc733e
BLAKE2b-256 checksum
How to use checksums
c4685f9e34edc922b6e29e94e4857d2593e6db89474afc829849cbd19ef72ff1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / mypy_pytest_parametrize-2026.10.5.1-py3-none-any.whl

Download URL mypy_pytest_parametrize-2026.10.5.1-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46963da42e30f35e05fc6b2508aa9167761de67836490a5cf5ed9c563946fa54
BLAKE2b-256 checksum
How to use checksums
4c78203545c44cd67b10e24f0d6946b902366e38dc38e171e8c0ada065088d79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.10.5.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page