/usr/lib/python3/dist-packages/positional-1.0.1.egg-info/PKG-INFO is in python3-positional 1.0.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | Metadata-Version: 1.1
Name: positional
Version: 1.0.1
Summary: Library to enforce positional or key-word arguments
Home-page: https://github.com/morganfainberg/positional
Author: Morgan Fainberg
Author-email: morgan.fainberg@gmail.com
License: UNKNOWN
Description: ==========
positional
==========
A decorator which enforces only some args may be passed positionally.
The Basics
==========
`positional` provides a decorator which enforces only some args may be passed
positionally. The idea and some of the code was taken from the oauth2 client
of the google-api client.
The decorator makes it easy to support Python 3 style key-word only
parameters. For example, in Python 3 it is possible to write:
.. code:: python
>>> def fn(pos1, *, kwonly1 kwonly=None):
... ...
All named parameters after `*` must be a keyword:
.. code:: python
>>> fn(10, 'kw1', 'kw2') # Raises exception.
>>> fn(10, kwonly1='kw1', kwonly2='kw2') # Ok.
To replicate this behaviour with the positional decorator you simply specify
how many arguments may be passed positionally.
First to import the decorator we typically use:
.. code:: python
>> from positional import positional
Replicating the Example above:
.. code:: python
>>> @positional(1)
... fn(pos1, kwonly1=None, kwonly2=None):
... ...
If no default value is provided to a keyword argument, it becomes a required
keyword argument:
.. code:: python
>>> @positional(0)
... def fn(required_kw):
... ...
This must be called with the keyword parameter:
.. code:: python
>>> fn() # Raises exception
>>> fn(10) # Raises Exception
>>> fn(required_kw=10) # OK
When defining instance or class methods always remember that in python the
first positional argument passed is the instance; you will need to account for
`self` and `cls`:
.. code:: python
>>> class MyClass(object):
...
... @positional(2)
... def my_method(self, pos1, kwonly1=None):
... ...
...
... @classmethod
... @positional(2)
... def my_method(cls, pos1, kwonly1=None):
... ...
If you would prefer not to account for `self` and `cls` you can use the
`method` and `classmethod` helpers which do not consider the initial
positional argument. So the following class is exactly the same as the one
above:
.. code:: python
>>> class MyClass(object):
...
... @positional.method(1)
... def my_method(self, pos1, kwonly1=None):
... ...
...
... @positional.classmethod(1)
... def my_method(cls, pos1, kwonly1=None):
... ...
If a value isn't provided to the decorator then it will enforce that
every variable without a default value will be required to be a kwarg:
.. code:: python
>>> @positional()
... def fn(pos1, kwonly1=None):
... ...
...
>>> fn(10) # Ok.
>>> fn(10, 20) # Raises exception.
>>> fn(10, kwonly1=20) # Ok.
This behaviour will work with the `positional.method` and
`positional.classmethod` helper functions as well:
.. code:: python
>>> class MyClass(object):
...
... @positional.classmethod()
... def my_method(cls, pos1, kwonly1=None):
... ...
...
>>> MyClass.my_method(10) # Ok.
>>> MyClass.my_method(10, 20) # Raises exception.
>>> MyClass.my_method(10, kwonly1=20) # Ok.
For compatibility reasons you may wish to not always raise an exception so
a WARN mode is available. Rather than raise an exception a warning will be
emitted.
.. code:: python
>>> @positional(1, enforcement=positional.WARN):
... def fn(pos1, kwonly=1):
... ...
Available modes are:
- positional.EXCEPT - the default, raise an exception.
- positional.WARN - emit a warning.
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
|