Skip to main content

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.typed included.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_artdeco-0.1.0.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_artdeco-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

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

Hashes for py_artdeco-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4465effb70fc312ec99f0b1e5271f1a340b6b48b6e0d269e0797836cb9829f0b
MD5 d09d4e20be07cfeb73eeed8624229d51
BLAKE2b-256 c01ca231208bac20824c2188527760e67100ac21d60bfecfc1fb1ca36183c821

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_artdeco-0.1.0.tar.gz:

Publisher: publish.yml on WimYedema/artdeco

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for py_artdeco-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1035591441d3c2a9d4abf07c1e894e182c6531bc0bd444b0b8fe170c599d204d
MD5 77e65a04f12a0fba23c2a87dfcab6aff
BLAKE2b-256 4101d31ccbf09ee9e18a551dce1395f3e2c15b111a8e6a98ceda3c4a7acd8f5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_artdeco-0.1.0-py3-none-any.whl:

Publisher: publish.yml on WimYedema/artdeco

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page