From e7ca211925cdc3259f936e3d4495ce71ee2847f9 Mon Sep 17 00:00:00 2001 From: Kyle Lahnakoski Date: Tue, 14 May 2024 22:12:30 -0400 Subject: [PATCH 1/2] update version number --- packaging/setup.py | 4 ++-- packaging/setuptools.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/setup.py b/packaging/setup.py index 2f24d22..e551032 100644 --- a/packaging/setup.py +++ b/packaging/setup.py @@ -8,13 +8,13 @@ description='Object destructuring of function parameters for Python!', extras_require={"tests":["mo-testing>=8.610.24119","mo-times>=5.609.24119","mo-json>=6.609.24119","mo-threads>=6.610.24119"]}, include_package_data=True, - install_requires=["mo-dots==10.623.24125"], + install_requires=["mo-dots==10.627.24136"], license='MPL 2.0', long_description='\n# More KWARGS!\n\nObject destructuring of function parameters for Python!\n\n[![PyPI Latest Release](https://img.shields.io/pypi/v/mo-kwargs.svg)](https://pypi.org/project/mo-kwargs/)\n [![Build Status](https://github.com/klahnakoski/mo-kwargs/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/klahnakoski/mo-kwargs/actions/workflows/build.yml)\n [![Coverage Status](https://coveralls.io/repos/github/klahnakoski/mo-kwargs/badge.svg?branch=dev)](https://coveralls.io/github/klahnakoski/mo-kwargs?branch=dev)\n[![Downloads](https://pepy.tech/badge/mo-kwargs)](https://pepy.tech/project/mo-kwargs)\n\n\n## Motivation\n\nJavascript has [object destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#object_destructuring), and it can be used for function parameters. This has a couple of benefts over Python\'s keyword arguments:\n\n* Extra caller parameters are ignored (eg `f({a, b, c})`)\n* Duplicate parameters are handled elegantly (eg `f({a, a})`) \n\nThe `mo-kwargs` library provides this functionality with the `@override` decorator, with additional benefits:\n \n * required parameters throw an error if missing, just like regular Python\n * all parameters, even ones not in the argument list, are passed in the optional `kwargs` parameter \n \nThe `@override` decorator adds a `kwargs` argument which can be passed a dict of call parameters; but unlike `**kwargs`, it will not raise duplicate key exceptions.\n\n## Provide default values\n\nWe decorate the `login()` function with `@override`. `username` is a required parameter, and `password` will default to `None`. \n\n @override\n def login(username, password=None):\n pass\n\nDefine some `dicts` for use with our `kwargs` parameter:\n\n creds = {"userame": "ekyle", "password": "password123"}\n alt_creds = {"username": "klahnakoski"}\n\n\nThe simplest case is when we use `kwargs` with no overrides\n\n login(kwargs=creds)\n # SAME AS\n login(**creds)\n # SAME AS\n login(username="ekyle", password="password123")\n\nYou may override any property in `kwargs`: In this case it is `password`\n\n login(password="123", kwargs=creds)\n # SAME AS\n login(username="ekyle", password="123")\n\nThere is no problem with overriding everything in `kwargs`:\n\n login(username="klahnakoski", password="asd213", kwargs=creds)\n # SAME AS\n login(username="klahnakoski", password="asd213")\n\nYou may continue to use `**kwargs`; which provides a way to overlay one parameter template (`creds`) with another (`alt_creds`)\n\n login(kwargs=creds, **alt_creds)\n # SAME AS\n login(username="klahnakoski", password="password123")\n\n## Handle too many parameters\n\nSometimes your method parameters come from a configuration file, or some other outside source which is outside your control. There may be more parameters than your method is willing to accept. \n\n creds = {"username": "ekyle", "password": "password123", "port":9000}\n def login(username, password=None):\n print(kwargs.get("port"))\n\nWithout `mo-kwargs`, passing the `creds` dictionary directly to `login()` would raise a key error\n\n >>> login(**creds)\n Traceback (most recent call last):\n File "", line 1, in \n TypeError: login() got an unexpected keyword argument \'port\'\n \nThe traditional solution is to pass the parameters explicitly:\n\n login(username=creds.username, password=creds.password)\n\nbut that can get get tedious when done often, or the parameter list get long. `mo-kwargs` allows you to pass the whole dictionary to the `kwargs` parameter; only the parameters used by the method are used:\n\n @override\n def login(username, password=None):\n pass\n \n login(kwargs=creds)\n # SAME AS\n login(username=creds.username, password=creds.password)\n\n## Package all parameters\n\nYour method can accept `kwargs` as a parameter. If it does, ensure it defaults to `None` so that it\'s not required.\n\n @override\n def login(username, password=None, kwargs=None):\n print(kwargs.get("username"))\n print(kwargs.get("port"))\n\n`kwargs` will always be a dict, possibly empty, with the full set of parameters. This is different from using `**kwargs` which contains only the remainder of the keyword parameters.\n\n >>> creds = {"username": "ekyle", "password": "password123", "port":9000}\n >>> login(**creds)\n ekyle\n 9000\n', long_description_content_type='text/markdown', name='mo-kwargs', packages=["mo_kwargs"], url='https://github.com/klahnakoski/mo-kwargs', - version='7.623.24125', + version='7.627.24136', zip_safe=False ) \ No newline at end of file diff --git a/packaging/setuptools.json b/packaging/setuptools.json index 36910cb..94aa9ce 100644 --- a/packaging/setuptools.json +++ b/packaging/setuptools.json @@ -18,7 +18,7 @@ "mo-threads>=6.610.24119" ]}, "include_package_data": true, - "install_requires": ["mo-dots==10.623.24125"], + "install_requires": ["mo-dots==10.627.24136"], "license": "MPL 2.0", "long_description": { "$concat": [ @@ -139,6 +139,6 @@ "name": "mo-kwargs", "packages": ["mo_kwargs"], "url": "https://github.com/klahnakoski/mo-kwargs", - "version": "7.623.24125", + "version": "7.627.24136", "zip_safe": false } \ No newline at end of file From 95d1c9493fbee10d60e1dd1c05d77263e86cb149 Mon Sep 17 00:00:00 2001 From: Kyle Lahnakoski Date: Tue, 14 May 2024 22:13:20 -0400 Subject: [PATCH 2/2] update lockfile --- tests/requirements.lock | 19 ++++++++++--------- tests/requirements.txt | 8 ++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/requirements.lock b/tests/requirements.lock index 41f9e59..d561c20 100644 --- a/tests/requirements.lock +++ b/tests/requirements.lock @@ -1,13 +1,14 @@ -# Tests pass with python 3.8 on 2024-05-04 and with these versions +# Tests pass with python 3.8 on 2024-05-15 and with these versions # pip install --no-deps -r tests/requirements.lock hjson==3.1.0 -mo-collections==5.608.24119 -mo-dots==10.623.24125 +mo-collections==5.623.24125 +mo-dots==10.627.24136 mo-future==7.584.24095 mo-imports==7.584.24095 -mo-json==6.609.24119 -mo-logs==8.608.24119 -mo-math==7.606.24115 -mo-testing==8.610.24119 -mo-threads==6.610.24119 -mo-times==5.609.24119 \ No newline at end of file +mo-json==6.624.24125 +mo-logs==8.623.24125 +mo-math==7.623.24125 +mo-testing==8.623.24125 +mo-threads==6.623.24125 +mo-times==5.623.24125 +pytz==2024.1 \ No newline at end of file diff --git a/tests/requirements.txt b/tests/requirements.txt index 43953a5..90433d6 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,4 @@ -mo-testing>=8.610.24119 -mo-times>=5.609.24119 -mo-json>=6.609.24119 -mo-threads>=6.610.24119 \ No newline at end of file +mo-testing>=8.623.24125 +mo-times>=5.623.24125 +mo-json>=6.624.24125 +mo-threads>=6.623.24125 \ No newline at end of file