Skip to main content

Build Status PyPI

mypy-strict-kwargs

Enforce using keyword arguments where possible.

For example, if we have a function which takes two regular argument, there are three ways to call it. With this plugin, mypy will only accept the form where keyword arguments are used.

"""Showcase errors when calling a function without naming the arguments."""


def add(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b


_ = add(a=1, b=2)  # With this plugin, ``mypy`` will only accept this form
_ = add(1, 2)  # type: ignore[call-arg]
_ = add(1, b=2)  # type: ignore[call-arg]

Why?

  • In the same spirit as a formatter - think black or ruff format - this lets you stop spending time discussing whether a function call should use keyword arguments.

  • Sometimes positional arguments are best at first, and then more and more are added and code becomes unclear, without anyone stopping to refactor to keyword arguments.

  • The type checker gives better errors when keyword arguments are used. For example, with positional arguments, you may see, Argument 5 to "add" has incompatible type "str"; expected "int". This requires that you count the arguments to see which one is wrong. With keyword arguments, you get Argument "e" to "add" has incompatible type "str"; expected "int".

Installation

pip install mypy-strict-kwargs

This is tested on Python 3.11+.

Configure mypy to use the plugin

Add the plugin to your mypy configuration file:

pyproject.toml:

[tool.mypy]

plugins = [
    "mypy_strict_kwargs",
]

mypy.ini or .mypy.ini:

[mypy]
plugins = mypy_strict_kwargs

setup.cfg:

[mypy]
plugins = mypy_strict_kwargs

Ignoring functions

You can ignore functions by adding configuration to your mypy configuration file.

pyproject.toml:

[tool.mypy_strict_kwargs]
ignore_names = ["main.func", "builtins.str"]

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

[mypy_strict_kwargs]
ignore_names = main.func, builtins.str

This is useful especially for builtins which can look strange with keyword arguments. For example, str(object=1) is not idiomatic.

To find the name of a function to ignore, set the following configuration:

pyproject.toml:

[tool.mypy_strict_kwargs]
debug = true

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

[mypy_strict_kwargs]
debug = true

Then run mypy and look for the debug output.

Metadata

Release files for mypy-strict-kwargs 2026.10.9

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-strict-kwargs 2026.10.9
File Size Uploaded
mypy_strict_kwargs-2026.10.9.tar.gz 59.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mypy-strict-kwargs 2026.10.9
File Interpreter ABI Platform
mypy_strict_kwargs-2026.10.9-py3-none-any.whl Python 3 none any Details

Total release size: 87.4 kB

Release files / mypy_strict_kwargs-2026.10.9.tar.gz

Download URL mypy_strict_kwargs-2026.10.9.tar.gz
Size 59.7 kB
Tags Source
SHA-256 checksum
How to use checksums
15838d00b80da3885ea6b1b9ac13d262caf6c3ab3692a1ca8f3809160da8fbbd
BLAKE2b-256 checksum
How to use checksums
6bf50b6ca861c55770b59b1f29afda89a48835770f85920dc6ca0a43cdc39b89
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 9, 2026.

Transparency log

Release files / mypy_strict_kwargs-2026.10.9-py3-none-any.whl

Download URL mypy_strict_kwargs-2026.10.9-py3-none-any.whl
Size 27.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15b1c85adfab732311511b595eefd922061cc89a014262692f3a6324cbe1e11c
BLAKE2b-256 checksum
How to use checksums
990ad5d99caec9bd885f45caa9ca8e56b45fd95b121c72fb0b1435afe0dddd18
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 9, 2026.

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