mo-kwargs
Object destructuring of function parameters for Python!
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-kwargsuv
uv add mo-kwargspoetry
poetry add mo-kwargsInstalling 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
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
overloadingProvides function and method overloading based…
permissive · top 15,000 on PyPI
overridesProvides a @override decorator that validates…
permissive · top 1,000 on PyPI
mo-dotsProvides null-safe dot-notation access to…
copyleft · top 15,000 on PyPI
wraptwrapt provides a Python module for building…
permissive · top 100 on PyPI
singleton-decoratorProvides a decorator that enforces singleton…
copyleft · top 15,000 on PyPI
redoRedo provides decorators, functions, and a…
copyleft · top 5,000 on PyPI
undecoratedStrips decorators from Python functions,…
permissive · top 15,000 on PyPI
mo-parsingmo-parsing is a PEG parser generator that lets…
permissive · top 15,000 on PyPI
mo-logsProvides structured JSON logging with…
copyleft · top 15,000 on PyPI
mo-sql-parsingParses SQL queries into JSON-serializable parse…
copyleft · top 15,000 on PyPI