# micheles/decorator

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/micheles-decorator).**

_How this analysis was created: the description and tags below were written by an AI model that read this project's README and public documentation pages; stars, license and language come straight from the GitHub API. The model does not read the source code._

907 stars · 116 forks · Python · BSD-2-Clause

## Links

- GitHub: https://github.com/micheles/decorator
- awesome-repositories: https://awesome-repositories.com/repository/micheles-decorator.md

## Topics

`metaprogramming` `python`

## Description

The project is a Python metaprogramming toolkit designed to build signature-preserving function decorators, generic dispatch functions, and context managers without losing metadata. It provides utilities for constructing custom function wrappers and converting generator functions or context managers into reusable decorators that automatically wrap execution blocks.

The library supports multi-argument generic function dispatch by routing calls based on runtime argument types and virtual base classes, complete with abstract base class and virtual ancestor resolution. It also includes capabilities for asynchronous coroutine decoration, class-to-decorator conversion, parameterized decorator factories, and upgrading third-party or legacy implementations to retain original function signatures, docstrings, and annotations.

Additional features encompass dynamic function generation tools for programmatically building new functions with custom names, signatures, and body templates at runtime. It also provides resource access state management wrappers that block execution or return alternative messages when target resources are unavailable.

## Tags

### Programming Languages & Runtimes

- [Function Decorators](https://awesome-repositories.com/f/programming-languages-runtimes/functional-programming-logic/function-decorators.md) — Builds custom Python function decorators that preserve original signatures, docstrings, and metadata without complex closure patterns.
- [Generator Context Transformers](https://awesome-repositories.com/f/programming-languages-runtimes/function-context-management/generator-context-transformers.md) — Converts generator functions and context managers into signature-preserving decorators that wrap execution blocks.
- [Function Signatures](https://awesome-repositories.com/f/programming-languages-runtimes/function-signatures.md) — Retains original function signatures, docstrings, annotations, and metadata across decorated functions for accurate runtime introspection. ([source](https://github.com/micheles/decorator#readme))
- [Generic](https://awesome-repositories.com/f/programming-languages-runtimes/function-signatures/function-registries/generic.md) — Maintains a lookup table of specialized implementations supporting inheritance hierarchies and virtual base classes.
- [Python Decorator Libraries](https://awesome-repositories.com/f/programming-languages-runtimes/functional-utility-libraries/python-decorator-libraries.md) — Provides utilities for building signature-preserving function decorators, generic dispatch functions, and context managers without losing metadata.
- [Multi-Argument Dispatchers](https://awesome-repositories.com/f/programming-languages-runtimes/generic-types/generic-functions/multi-argument-dispatchers.md) — Routes function calls to specialized implementations based on the runtime types of multiple positional arguments.
- [Metaprogramming](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/language-features/metaprogramming.md) — Constructs and transforms functions dynamically at runtime with custom names, signatures, and annotations for advanced metaprogramming tasks.
- [Multi-Argument Generic Dispatches](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/functional/generic-function-definitions/generic-dispatch-mechanisms/multi-argument-generic-dispatches.md) — Dispatches function calls to specialized implementations based on the runtime types of chosen function arguments, supporting virtual base classes. ([source](https://github.com/micheles/decorator/blob/4.2.1/docs/tests.documentation.rst))
- [Python Generic Function Dispatchers](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/functional/generic-function-definitions/python-generic-function-dispatchers.md) — Implements generic functions in Python that route execution based on the runtime types of one or more arguments.
- [Runtime Type Dispatching](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-execution-environments/runtime-environments/runtimes/type-definition-systems/runtime-type-dispatching.md) — Routes function calls to specialized implementations dynamically by evaluating the runtime types of specified positional arguments.

### Operating Systems & Systems Programming

- [Asynchronous Coroutine Decorators](https://awesome-repositories.com/f/operating-systems-systems-programming/asynchronous-i-o-libraries/coroutine-based-asynchronous-i-o/python-coroutine-implementations/asynchronous-coroutine-decorators.md) — Decorates asynchronous coroutine functions while preserving their execution semantics and inspection compatibility. ([source](https://github.com/micheles/decorator/blob/4.2.1/docs/tests.documentation.rst))

### Software Engineering & Architecture

- [Generator-to-Context Converters](https://awesome-repositories.com/f/software-engineering-architecture/generator-to-context-converters.md) — Transforms generator functions into context managers that act as signature-preserving execution decorators. ([source](https://github.com/micheles/decorator/blob/4.3.2/docs/tests.documentation.rst))
- [Context Manager Function Wrappers](https://awesome-repositories.com/f/software-engineering-architecture/higher-order-function-wrapping/function-decorators/context-manager-function-wrappers.md) — Converts Python generator functions and context managers into signature-preserving decorators that automatically wrap execution blocks.
- [Reusable Function Wrappers](https://awesome-repositories.com/f/software-engineering-architecture/higher-order-function-wrapping/library-function-wrappers/reusable-function-wrappers.md) — Defines reusable function wrappers that alter or enhance the behavior of target functions without modifying source code. ([source](https://github.com/micheles/decorator/blob/4.0.0/documentation.rst](https://github.com/micheles/decorator/blob/4.0.0/documentation.rst))
- [Signature Metadata Propagations](https://awesome-repositories.com/f/software-engineering-architecture/signature-metadata-propagations.md) — Copies original docstrings, annotations, and parameter specifications directly onto wrapper functions to maintain tool inspection compatibility.
- [Class-Based Decorators](https://awesome-repositories.com/f/software-engineering-architecture/class-based-decorators.md) — Transforms class definitions into callable decorators that instantiate the class or execute logic when applied to target functions. ([source](https://github.com/micheles/decorator/blob/4.2.1/docs/tests.documentation.rst))
- [Decorator Factories](https://awesome-repositories.com/f/software-engineering-architecture/composite-state-definitions/atomic-state-primitives/parameterized-factories/decorator-factories.md) — Constructs parameterized decorator factories that accept configuration arguments for flexible function modification. ([source](https://github.com/micheles/decorator#readme))
- [Dynamic Function Generators](https://awesome-repositories.com/f/software-engineering-architecture/dynamic-function-generators.md) — Constructs new functions programmatically at runtime with custom names, signatures, and body templates for advanced metaprogramming tasks. ([source](https://github.com/micheles/decorator/blob/3.4.2/documentation.rst))
- [Context Managers](https://awesome-repositories.com/f/software-engineering-architecture/resource-lifecycle-management/context-managers.md) — Provides a metaprogramming toolkit that converts generator functions and context managers into reusable signature-preserving function decorators.
