Python decorators library
Project description
Python More Decorators
Python More Decorators is a handy library to simplify your code with a collection of useful decorators.
- Works with type checking (tested with
mypy)
Installation
pip
pip install python-more-decorators
poetry
poetry add python-more-decorators
Features
Evaluate runtime-default arguments
Sometimes we are just tired of polluting the function arguments declaration with None as argument: Optional[MutableType] = None.
Or, we have all been here: having some_list_argument: list[T] = [] or now: float = time.time() in arguments.
The worst thing is that it still runs.
We now have:
from more_decorators.runtime_defaults import evaluate_runtime_defaults, runtime_default
@evaluate_runtime_defaults
def foo(now: float = runtime_default(time.time)): # think of it like `now: float = time.time()`
# but evaluated every time upon function call
return f"Unix Timestamp: {now}"
...and more to come.
License
This library is licensed under the MIT License. See the LICENSE file for details.
Development
See CONTRIBUTING.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file more_decorators-0.1.1.tar.gz.
File metadata
- Download URL: more_decorators-0.1.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.14 Linux/6.5.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8adb937e650ef2bc9243fd7e91375333b4418185f9248a4f79c61ca2fa64bf2
|
|
| MD5 |
c1b4b972e10b93785fa17864bc500d18
|
|
| BLAKE2b-256 |
56546e7530e4ebac6deda2f2d3f39c3240bc5d3ef95c6ac6ef036be12f33d933
|
File details
Details for the file more_decorators-0.1.1-py3-none-any.whl.
File metadata
- Download URL: more_decorators-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.14 Linux/6.5.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
430c4faa6215e707832237b1eed5fb5bafe525a715823ce28584d5d8bb0abe04
|
|
| MD5 |
fe3b8c187fc3413de4423a17918934db
|
|
| BLAKE2b-256 |
76ed330ec0b2f99b37ffb806ea48c4ad3e59b2c0d80840dd2186a3a7e997a79b
|