Update decorators to more correctly set function metadata.

Review Request #13378 — Created Oct. 25, 2023 and submitted — Latest diff uploaded

Information

Djblets
release-3.x

Reviewers

Our API decorators and @augment_method_from attempted to set their own
function metadata (__name__, __doc__, etc.), rather than utilizing
Python's @wraps/update_wrapper functions. This meant that we weren't
keeping up with all the latest attributes, such as __annotations__ and
__qualname__.

This change switches some of our decorators over to this. It also
simplifies @webapi_response_errors to not require an inner function
call, modifying state on the original function instead, reducing API
overhead.

Unit tests pass.

Verified I could access the original function state (__qualname__ in
particular) when working with these functions.

Changes between revision 1 and 2

orig
1
2

Commits

Summary ID Author
Update decorators to more correctly set function metadata.
Our API decorators and `@augment_method_from` attempted to set their own function metadata (`__name__`, `__doc__`, etc.), rather than utilizing Python's `@wraps`/`update_wrapper` functions. This meant that we weren't keeping up with all the latest attributes, such as `__annotations__` and `__qualname__`. This change switches some of our decorators over to this. It also simplifies `@webapi_response_errors` to not require an inner function call, modifying state on the original function instead, reducing API overhead.
c006c2c7dac9ce4ae7aa7b5eb48805aa7ba20836 Christian Hammond
Update decorators to more correctly set function metadata.
Our API decorators and `@augment_method_from` attempted to set their own function metadata (`__name__`, `__doc__`, etc.), rather than utilizing Python's `@wraps`/`update_wrapper` functions. This meant that we weren't keeping up with all the latest attributes, such as `__annotations__` and `__qualname__`. This change switches some of our decorators over to this. It also simplifies `@webapi_response_errors` to not require an inner function call, modifying state on the original function instead, reducing API overhead.
4f22c3b380da164b586880263b4e5e46c34820ab Christian Hammond
djblets/webapi/decorators.py
Loading...