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.19

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.19
File Size Uploaded Provenance
mypy_strict_kwargs-2026.10.19.tar.gz 60.2 kB With provenance Details

Built distribution (wheel)

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

Total release size: 88.0 kB

Release files / mypy_strict_kwargs-2026.10.19.tar.gz

Download URL mypy_strict_kwargs-2026.10.19.tar.gz
Size 60.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c94224b78c671ee717c7bbe47d72aee46314acbece42de1e59220f9bbae92294
BLAKE2b-256 checksum
How to use checksums
86717a9a7319ea3cf1fdf950492808555a66456f8b5aac6d91a0d352d8eeab5b
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 19, 2026.

Transparency log

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

Download URL mypy_strict_kwargs-2026.10.19-py3-none-any.whl
Size 27.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4cf1fdfa6c4b1d3ba59c223188a084c34236da3826b9c8763b164ea714ee9c56
BLAKE2b-256 checksum
How to use checksums
59351c0884c3705ab558315e86cddbc6dbbc1cd6d56087237e4cbf5d92c4bc35
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 19, 2026.

Transparency log

Security for mypy-strict-kwargs 2026.10.19

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mypy_strict_kwargs-2026.10.19.tar.gz

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 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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