param
Enhanced function parameters
Installation
pip install git+https://github.com/tombulled/param.git@main
Usage
Functions
The @params annotation works seamlessly with functions:
from param import Param, params
@params
def get(url: str, params: dict = Param(default_factory=dict)):
print("GET", url, params)
>>> get("https://httpbin.com/get")
GET https://httpbin.com/get {}
Classes
The @params annotation also works seamlessly with classes. Importantly, the @params annotation should be specified before @staticmethod or @classmethod.
from param import Param, params
class MyClass:
@params
def get(self, url: str, params: dict = Param(default_factory=dict)):
print("GET", url, params)
@classmethod
@params
def post(cls, url: str, params: dict = Param(default_factory=dict)):
print("POST", url, params)
@staticmethod
@params
def put(url: str, params: dict = Param(default_factory=dict)):
print("PUT", url, params)
>>> obj = MyClass()
>>>
>>> obj.get("https://httpbin.com/get")
GET https://httpbin.com/get {}
>>>
>>> obj.post("https://httpbin.com/post")
POST https://httpbin.com/post {}
>>> MyClass.post("https://httpbin.com/post")
POST https://httpbin.com/post {}
>>>
>>> obj.put("https://httpbin.com/put")
PUT https://httpbin.com/put {}
>>> MyClass.put("https://httpbin.com/put")
PUT https://httpbin.com/put {}
Metadata
Release files for tombulled-param 0.1.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tombulled_param-0.1.14.tar.gz | 7.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tombulled_param-0.1.14-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.5 kB
Release files / tombulled_param-0.1.14.tar.gz
| Download URL | tombulled_param-0.1.14.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e673165dd6514db2188cf71fa8ed016efc24148ab6ae943bd85d04177da1be9
|
|
BLAKE2b-256 checksum How to use checksums |
2e378ee9c9d29dc00b11dd808ea5c1a7b74b4fb552f899e66359a3e81280e30f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.8.10 Linux/5.4.0-131-generic
|
Release files / tombulled_param-0.1.14-py3-none-any.whl
| Download URL | tombulled_param-0.1.14-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46d6abddc21304b9839ed4d034e67fac046eade78f7bbb789af99cd77f353e97
|
|
BLAKE2b-256 checksum How to use checksums |
96c417e9e2c5f0bfd482f2af5b4ffcaf76f821d9498342b466c755e200e3bc6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.8.10 Linux/5.4.0-131-generic
|