{"id":21583,"library":"mo-kwargs","title":"mo-kwargs","description":"Python library for object destructuring of function parameters using typed dictionaries/objects. Current version 8.703.26061. Very frequent releases (multiple per month).","status":"active","version":"8.703.26061","language":"python","source_language":"en","source_url":"https://github.com/klahnakoski/mo-kwargs","tags":["kwargs","destructuring","decorator","parameters"],"install":[{"cmd":"pip install mo-kwargs","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Used for dot-notation access and object conversion","package":"mo-dots","optional":true},{"reason":"Used by some older patterns","package":"mo-imports","optional":true}],"imports":[{"note":"Most common and recommended import.","symbol":"kwargs","correct":"from mo_kwargs import kwargs"},{"note":"Use to override destructured kwargs.","symbol":"override","correct":"from mo_kwargs import override"},{"note":"Used to set default values after destructuring.","symbol":"set_default","correct":"from mo_kwargs import set_default"}],"quickstart":{"code":"from mo_kwargs import kwargs\n\n@kwargs\nclass MyClass:\n    def __init__(self, a, b=10, c=None):\n        self.a = a\n        self.b = b\n        self.c = c\n\nobj = MyClass({'a': 1, 'c': 2})\nprint(obj.a, obj.b, obj.c)  # 1 10 2","lang":"python","description":"Decorate a class with @kwargs to automatically destructure a dictionary argument into constructor parameters."},"warnings":[{"fix":"Add @kwargs decorator to classes that previously worked without it, or adjust parameter names to match dictionary keys exactly.","message":"Version 8 introduced major changes: the default destructuring changed from 'typed' to 'explicit' mode. Existing code relying on implicit type matching may fail. Use @kwargs to opt into typed mode if needed.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Ensure that any parameter you want to receive from a dict does not start with underscore.","message":"The library uses the underscore (_) to mark positional parameters. Parameters starting with underscore are not destructured from the input dict; they remain as positional arguments.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace 'from mo_kwargs import kwargs_decorator' with 'from mo_kwargs import kwargs'.","message":"The old pattern using 'from mo_kwargs import kwargs_decorator' is deprecated and may be removed. Use the kwargs function directly.","severity":"deprecated","affected_versions":"<8.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure the argument passed to the decorated class is a dictionary, not None. Add a guard or default empty dict.","cause":"The @kwargs decorator expects a dict-like argument; passing None causes this error.","error":"AttributeError: 'NoneType' object has no attribute 'items'"},{"fix":"Remove the duplicate argument. Either pass via dict or as keyword, not both.","cause":"The same key appears both in the input dict and as a positional argument, often due to mixing decorator usage.","error":"TypeError: __init__() got multiple values for argument 'x'"},{"fix":"Use 'from mo_kwargs import kwargs' instead.","cause":"Old import path removed in recent versions.","error":"ImportError: cannot import name 'kwargs_decorator' from 'mo_kwargs'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}