skillfed

mo-kwargs

Object destructuring of function parameters for Python!

mo-kwargs v8.703.26061 119.0K downloads/30d#12,093 on PyPI3
Copyleft license MPL 2.0 Active released

What it is and what it does

mo-kwargs is a decorator library that brings JavaScript-style object destructuring to Python function parameters. It provides an `@override` decorator that adds a `kwargs` parameter to decorated functions, allowing you to pass a dictionary of parameters that will be unpacked and merged with explicit arguments. Unlike `**kwargs`, this approach ignores extra keys in the dictionary instead of raising a TypeError, and allows explicit parameters to override values from the dictionary.

The primary use case is handling parameter sets from external sources—configuration files, APIs, or dynamic data structures—where you cannot control whether extra keys are present. The decorator ensures required parameters are still enforced, optional parameters get their defaults, and all parameters (used or not) are available in the `kwargs` dict if the function accepts it. It works with regular Python functions, instance methods, and class methods.

Use it for:

  • Load function parameters from a config file that may contain extra keys you don't need
  • Overlay multiple parameter dictionaries with explicit overrides (e.g., base config + user overrides)
  • Accept parameter bundles from external APIs without manually extracting each field
  • Collect all parameters passed to a function in a single dict for logging or inspection
  • Simplify function calls when parameters come from a dynamic source with unknown keys

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides an `@override` decorator that lets you pass function parameters as a dictionary via a `kwargs` argument, ignoring extra keys and allowing parameter overrides without raising errors.

Yes, if you frequently work with parameter dictionaries from external sources and want to avoid boilerplate extraction or TypeError handling. The low install friction, active maintenance, and lack of security issues make it a safe choice. The MPL 2.0 copyleft license is a minor consideration only if you plan to modify and redistribute the package itself.

Install

mo-kwargs on PyPI

pip

pip install mo-kwargs

uv

uv add mo-kwargs

poetry

poetry add mo-kwargs

Installing mo-kwargs

Before you install

Low friction: pure Python wheel with a single runtime dependency (mo-dots). Actively maintained as of March 2026, with a long release history since 2017.

License in practice

MPL 2.0 is a copyleft license; you must disclose source and license any modifications to this package, though it permits commercial use and does not require derivative works to adopt the same license.

Quickstart

from mo_kwargs import override

@override
def login(username, password=None):
    return f"Logged in as {username}"

creds = {"username": "user", "password": "pass", "extra": "ignored"}
result = login(kwargs=creds)

Verify before relying

  • Whether mo-dots adds meaningful install friction or is a lightweight utility dependency
  • Real-world performance impact of the decorator on function call overhead

Package facts

License MPL 2.0 (copyleft)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 1 — mo-dots
Maintenance actively maintained — 165 days since the last release
Last repo commit
First released
Downloads 118,992/month — #12,093 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mo_kwargs-8.703.26061-py3-none-any.whl

Development Status :: 4 - BetaLicense :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

function parameter destructuringkwargs decorator pythonpass dict as function argumentsobject destructuring parametersflexible function parameter binding
decoratorparameter-handling

More Libraries packages