Skip to content

Decorators Module ​

Provides utility decorators used throughout the library.
Includes decorators for deprecating callables and configuring MyPyC compiler attributes.

deprecated ​

python
class deprecated(self, message: LiteralString, **kwargs: Any)

Safe implementation of deprecated that emits warnings at runtime but handles mypyc compiled functions gracefully without crashing.


  • message – A string message to display when the deprecated function is called.
  • **kwargs – Additional keyword arguments to pass to the underlying warnings.warn function.

Example Usage ​

python
@deprecated("This function is deprecated. Use `new_function()` instead.")
def old_function():
    ...

mypyc_attr() ​

python
def mypyc_attr[T](**kwargs: Any) -> Callable[[T], T]

A custom decorator that wraps mypy_extensions.mypyc_attr when available, or acts as a no-op decorator when mypy_extensions is not installed.
This allows the use of mypyc compilation hints for compiling without making mypy_extensions a required dependency.


  • **kwargs – Keyword arguments to pass to mypy_extensions.mypyc_attr if available.

Example Usage ​

python
@mypyc_attr(native_class=False)
class MyClass:
    ...

Released under the MIT License.