mypy-strict-kwargs is a Mypy plugin that enforces the use of keyword arguments for function parameters that have default values, promoting clearer and less error-prone function calls. As of its current version, 2026.1.12, it follows a date-based release cadence with frequent updates, often several times a year.
pip install mypy-strict-kwargsVerified import paths — ran on the pinned version, not inferred.
To use mypy-strict-kwargs, first install it, then enable the plugin in your `mypy.ini` configuration file. The plugin will then enforce that arguments with default values are passed as keyword arguments when a positional argument would suffice, ensuring clarity in function calls. Run `mypy main.py` to see the effect.
Be aware of these exclusions. If strict keyword enforcement is needed for these cases, alternative Mypy checks or refactoring might be required.
Ensure your development environment and Mypy execution environment are using Python 3.10 or higher. Upgrade Python if necessary.
Add `plugins = mypy_strict_kwargs.plugin` under the `[mypy]` section in your Mypy configuration file (`mypy.ini`, `pyproject.toml`, etc.).
Understand that the plugin's scope is for arguments with defaults. For strict keyword-only enforcement on arguments without defaults, use `*, arg: type` in your function signature.