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
more_decorators-0.1.1.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for more_decorators-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 430c4faa6215e707832237b1eed5fb5bafe525a715823ce28584d5d8bb0abe04 |
|
MD5 | fe3b8c187fc3413de4423a17918934db |
|
BLAKE2b-256 | 76ed330ec0b2f99b37ffb806ea48c4ad3e59b2c0d80840dd2186a3a7e997a79b |