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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mypy_strict_kwargs-2026.8.25.1.tar.gz (56.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mypy_strict_kwargs-2026.8.25.1-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file mypy_strict_kwargs-2026.8.25.1.tar.gz.

File metadata

  • Download URL: mypy_strict_kwargs-2026.8.25.1.tar.gz
  • Upload date:
  • Size: 56.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mypy_strict_kwargs-2026.8.25.1.tar.gz
Algorithm Hash digest
SHA256 f65e1d4ee9557dd1392d9bcb13fb8e2fbd925e04d145a8c8a3571e0aa67ab009
MD5 586e7ec594a509067c429e18fe8ba964
BLAKE2b-256 f0f4dde18a0a2289aaef098a46a0b31b4c552b7d1e2db09032c87237118f9561

See more details on using hashes here.

Provenance

The following attestation bundles were made for mypy_strict_kwargs-2026.8.25.1.tar.gz:

Publisher: release.yml on adamtheturtle/mypy-strict-kwargs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mypy_strict_kwargs-2026.8.25.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mypy_strict_kwargs-2026.8.25.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94d73bce6157737835f8e5b04ff72916dbc554f243b9192b006603e8ba3e326b
MD5 402507c74562e3e48361e4c56450fb0d
BLAKE2b-256 105e411eebd9e9871700edc0f16b8cd7e22b167ea5f95c39556627c651832db4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mypy_strict_kwargs-2026.8.25.1-py3-none-any.whl:

Publisher: release.yml on adamtheturtle/mypy-strict-kwargs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2026.8.25.1 This release

2 files

2026.8.25

2 files

2026.8.20.1

2 files

2026.8.20

2 files

2026.8.19

2 files

2026.7.19.1

2 files

2026.7.19

2 files

2026.5.20.1

2 files

2026.5.20

2 files

2026.5.19

2 files

2026.1.12

2 files

2025.4.3

2 files

2025.3.28

2 files

2024.12.25

2 files

2024.12.24

2 files

2024.12.23.2

2 files

2024.12.23.1

2 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