tet.decorators package
Decorator utilities for Tet applications.
This module provides useful decorators:
deprecated()- Mark functions as deprecatedreify_attr- Cached property with configurable attribute name
Example
Marking a function as deprecated:
from tet.decorators import deprecated
@deprecated
def old_function():
pass
Using reify_attr for cached properties:
from tet.decorators import reify_attr
class MyClass:
@reify_attr
def expensive_computation(self):
# This will only be called once per instance
return compute_something()
- tet.decorators.deprecated(func)[source]
This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.
- class tet.decorators.reify_attr(wrapped)[source]
Bases:
objectA cached property descriptor that uses the actual attribute name.
Unlike Pyramid’s
reifywhich gets the attribute name from the decorated method,reify_attruses the name of the actual attribute it’s assigned to. This is determined via__set_name__, falling back to finding the attribute on the class if__set_name__is not called (e.g., when the descriptor is assigned dynamically).This pattern is useful as a building block for descriptors like
autowiredin pyramid_di, where the descriptor needs to know its attribute name to cache the resolved value on the instance.