Method-aware sync/async decorator factories for Python.
Project description
artdeco
Method-aware decorator factories for Python functions and methods, with support for both synchronous and asynchronous decorator implementations.
Features
- Create decorators that work for plain functions and bound instance methods.
- Use the same high-level API for sync and async decorator implementations.
- Prevent mismatched usage (sync decorator applied to async function, and vice versa).
- Typed package with
py.typedincluded.
Installation
pip install py-artdeco
Quick Start
from artdeco import decorator
@decorator()
def log(call, prefix: str):
print(prefix, "calling")
return call()
@log("DEBUG:")
def add(a: int, b: int) -> int:
return a + b
assert add(1, 2) == 3
Async example:
from artdeco import decorator
@decorator()
async def traced(call, prefix: str):
print(prefix, "before")
return await call()
@traced("ASYNC")
async def work(x: int) -> int:
return x * 2
Development
This project uses uv for environment and dependency management.
Install tools and dependencies:
uv sync --group dev
Run checks:
uv run ruff check .
uv run pytest
uv run pyright src
Run typing tests:
uv run pyright src tests/typing
Build and validate distribution metadata:
uv build
uv run twine check dist/*
License
MIT, see LICENSE.
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 py_artdeco-0.1.0.tar.gz.
File metadata
- Download URL: py_artdeco-0.1.0.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4465effb70fc312ec99f0b1e5271f1a340b6b48b6e0d269e0797836cb9829f0b
|
|
| MD5 |
d09d4e20be07cfeb73eeed8624229d51
|
|
| BLAKE2b-256 |
c01ca231208bac20824c2188527760e67100ac21d60bfecfc1fb1ca36183c821
|
Provenance
The following attestation bundles were made for py_artdeco-0.1.0.tar.gz:
Publisher:
publish.yml on WimYedema/artdeco
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_artdeco-0.1.0.tar.gz -
Subject digest:
4465effb70fc312ec99f0b1e5271f1a340b6b48b6e0d269e0797836cb9829f0b - Sigstore transparency entry: 1208237054
- Sigstore integration time:
-
Permalink:
WimYedema/artdeco@ff2e82667d6961816686d1188b95df53f48a18b0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/WimYedema
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ff2e82667d6961816686d1188b95df53f48a18b0 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file py_artdeco-0.1.0-py3-none-any.whl.
File metadata
- Download URL: py_artdeco-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1035591441d3c2a9d4abf07c1e894e182c6531bc0bd444b0b8fe170c599d204d
|
|
| MD5 |
77e65a04f12a0fba23c2a87dfcab6aff
|
|
| BLAKE2b-256 |
4101d31ccbf09ee9e18a551dce1395f3e2c15b111a8e6a98ceda3c4a7acd8f5f
|
Provenance
The following attestation bundles were made for py_artdeco-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on WimYedema/artdeco
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_artdeco-0.1.0-py3-none-any.whl -
Subject digest:
1035591441d3c2a9d4abf07c1e894e182c6531bc0bd444b0b8fe170c599d204d - Sigstore transparency entry: 1208237114
- Sigstore integration time:
-
Permalink:
WimYedema/artdeco@ff2e82667d6961816686d1188b95df53f48a18b0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/WimYedema
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ff2e82667d6961816686d1188b95df53f48a18b0 -
Trigger Event:
workflow_dispatch
-
Statement type: