{ "info": { "author": "Morgan Fainberg", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 7 - Inactive", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5" ], "description": "==========\npositional\n==========\n\nA decorator which enforces only some args may be passed positionally. This library is minimally maintained and should only be used in cases of Python 2 to Python 3 conversions. Please write only Python 3 code going forward.\n\n|PyPi|\n\n|Build Status|\n\n|Documentation Status|\n\nThe Basics\n==========\n\n`positional` provides a decorator which enforces only some args may be passed\npositionally. The idea and some of the code was taken from the oauth2 client\nof the google-api client.\n\nThe decorator makes it easy to support Python 3 style key-word only\nparameters. For example, in Python 3 it is possible to write:\n\n.. code:: python\n\n >>> def fn(pos1, *, kwonly1, kwonly2=None):\n ... ...\n\nAll named parameters after `*` must be a keyword:\n\n.. code:: python\n\n >>> fn(10, 'kw1', 'kw2') # Raises exception.\n >>> fn(10, kwonly1='kw1', kwonly2='kw2') # Ok.\n\nTo replicate this behaviour with the positional decorator you simply specify\nhow many arguments may be passed positionally.\n\nFirst to import the decorator we typically use:\n\n.. code:: python\n\n >> from positional import positional\n\nReplicating the Example above:\n\n.. code:: python\n\n >>> @positional(1)\n ... fn(pos1, kwonly1=None, kwonly2=None):\n ... ...\n\nIf no default value is provided to a keyword argument, it becomes a required\nkeyword argument:\n\n.. code:: python\n\n >>> @positional(0)\n ... def fn(required_kw):\n ... ...\n\nThis must be called with the keyword parameter:\n\n.. code:: python\n\n >>> fn() # Raises exception\n >>> fn(10) # Raises Exception\n >>> fn(required_kw=10) # OK\n\nWhen defining instance or class methods always remember that in python the\nfirst positional argument passed is the instance; you will need to account for\n`self` and `cls`:\n\n.. code:: python\n\n >>> class MyClass(object):\n ...\n ... @positional(2)\n ... def my_method(self, pos1, kwonly1=None):\n ... ...\n ...\n ... @classmethod\n ... @positional(2)\n ... def my_method(cls, pos1, kwonly1=None):\n ... ...\n\n\n\nIf you would prefer not to account for `self` and `cls` you can use the\n`method` and `classmethod` helpers which do not consider the initial\npositional argument. So the following class is exactly the same as the one\nabove:\n\n.. code:: python\n\n >>> class MyClass(object):\n ...\n ... @positional.method(1)\n ... def my_method(self, pos1, kwonly1=None):\n ... ...\n ...\n ... @positional.classmethod(1)\n ... def my_method(cls, pos1, kwonly1=None):\n ... ...\n\n\nIf a value isn't provided to the decorator then it will enforce that\nevery variable without a default value will be required to be a kwarg:\n\n.. code:: python\n\n >>> @positional()\n ... def fn(pos1, kwonly1=None):\n ... ...\n ...\n >>> fn(10) # Ok.\n >>> fn(10, 20) # Raises exception.\n >>> fn(10, kwonly1=20) # Ok.\n\nThis behaviour will work with the `positional.method` and\n`positional.classmethod` helper functions as well:\n\n.. code:: python\n\n >>> class MyClass(object):\n ...\n ... @positional.classmethod()\n ... def my_method(cls, pos1, kwonly1=None):\n ... ...\n ...\n >>> MyClass.my_method(10) # Ok.\n >>> MyClass.my_method(10, 20) # Raises exception.\n >>> MyClass.my_method(10, kwonly1=20) # Ok.\n\nFor compatibility reasons you may wish to not always raise an exception so\na WARN mode is available. Rather than raise an exception a warning will be\nemitted.\n\n.. code:: python\n\n >>> @positional(1, enforcement=positional.WARN):\n ... def fn(pos1, kwonly=1):\n ... ...\n\nAvailable modes are:\n\n- positional.EXCEPT - the default, raise an exception.\n- positional.WARN - emit a warning.\n\n\n.. |Build Status| image:: https://travis-ci.org/morganfainberg/positional.svg?branch=master\n :target: https://travis-ci.org/morganfainberg/positional\n.. |Documentation Status| image:: https://readthedocs.org/projects/positional/badge/?version=latest\n :target: http://positional.readthedocs.org/en/latest/?badge=latest\n.. |PyPi| image:: https://badge.fury.io/py/positional.png\n :target: http://badge.fury.io/py/positional\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "positional", "package_url": "https://pypi.org/project/positional/", "platform": "", "project_url": "https://pypi.org/project/positional/", "project_urls": null, "release_url": "https://pypi.org/project/positional/1.2.1/", "requires_dist": null, "requires_python": "", "summary": "Library to enforce positional or key-word arguments (deprecated/unmaintained)", "version": "1.2.1" }, "last_serial": 3079800, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "3d65d446323aeef3a818451192a83278", "sha256": "ab4db9940bf7b20225fdcb49628b12013147237ba291715503195b523e773253" }, "downloads": -1, "filename": "positional-1.0.0.tar.gz", "has_sig": false, "md5_digest": "3d65d446323aeef3a818451192a83278", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16372, "upload_time": "2016-01-14T01:47:11", "url": "https://files.pythonhosted.org/packages/20/be/b3d04231d83a850773eb7d18c15cde8cb53331a59db96e31129d2a3ddfc2/positional-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "b8d7991e0d9b697ec23aaee34d6abb31", "sha256": "54a73f3593c6e30e9cdd0a727503b7c5dddbb75fb78bb681614b08dfde2bc444" }, "downloads": -1, "filename": "positional-1.0.1.tar.gz", "has_sig": false, "md5_digest": "b8d7991e0d9b697ec23aaee34d6abb31", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16398, "upload_time": "2016-01-17T20:51:04", "url": "https://files.pythonhosted.org/packages/c6/8a/b0937216915330d7007dd69fb816c042904684d1e1165612b76070f4c2a2/positional-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "98920e4a857edf9e75714f1c351436fe", "sha256": "e2d1e3a6a2abbc1820c5dfa72f0c8fc4b56eebbb6ccd7ee25b626c34b902c144" }, "downloads": -1, "filename": "positional-1.1.0.tar.gz", "has_sig": false, "md5_digest": "98920e4a857edf9e75714f1c351436fe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15932, "upload_time": "2016-04-19T19:13:48", "url": "https://files.pythonhosted.org/packages/bf/a8/bc656a556a60b76c32830b57279f51714ab7c6366fd243d6ea86b6fcad46/positional-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "c82903c32c1aec1ac0f0f6e166ef4e2e", "sha256": "ef845fa46ee5a11564750aaa09dd7db059aaf39c44c901b37181e5ffa67034b0" }, "downloads": -1, "filename": "positional-1.1.1.tar.gz", "has_sig": false, "md5_digest": "c82903c32c1aec1ac0f0f6e166ef4e2e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15987, "upload_time": "2016-06-26T21:08:39", "url": "https://files.pythonhosted.org/packages/83/73/1e2c630d868b73ecdea381ad7b081bc53888c07f1f9829699d277a2859a8/positional-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "cf34a3544538570681e3d40b7a53d4d6", "sha256": "14e5b502bad1bbccade474602ac773bd9d88aaf3b016985747ea992567f9597b" }, "downloads": -1, "filename": "positional-1.1.2.tar.gz", "has_sig": false, "md5_digest": "cf34a3544538570681e3d40b7a53d4d6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16434, "upload_time": "2017-07-27T01:37:17", "url": "https://files.pythonhosted.org/packages/8c/16/64a4fa0967c486380468dca18867d22ac1c17bba06349e31ace77c7757f7/positional-1.1.2.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "4afcffd8e2ba733fd7a50f137a2ee893", "sha256": "cf48ea169f6c39486d5efa0ce7126a97bed979a52af6261cf255a41f9a74453a" }, "downloads": -1, "filename": "positional-1.2.1.tar.gz", "has_sig": false, "md5_digest": "4afcffd8e2ba733fd7a50f137a2ee893", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16530, "upload_time": "2017-08-08T00:24:46", "url": "https://files.pythonhosted.org/packages/24/7e/3b1450db76eb48a54ea661a43ae00950275e11840042c5217bd3b47b478e/positional-1.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4afcffd8e2ba733fd7a50f137a2ee893", "sha256": "cf48ea169f6c39486d5efa0ce7126a97bed979a52af6261cf255a41f9a74453a" }, "downloads": -1, "filename": "positional-1.2.1.tar.gz", "has_sig": false, "md5_digest": "4afcffd8e2ba733fd7a50f137a2ee893", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16530, "upload_time": "2017-08-08T00:24:46", "url": "https://files.pythonhosted.org/packages/24/7e/3b1450db76eb48a54ea661a43ae00950275e11840042c5217bd3b47b478e/positional-1.2.1.tar.gz" } ] }