You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
For consumer classes that inherit consumer methods (i.e., methods decorated with @uplink.get, @uplink.post, etc.) from one or more parent classes, uplink decorators such as@response_handler or @timeout are not applied to those inherited methods when these decorators are used as class-level decorators. In other words, these decorators are strictly applied to consumer methods that are directly defined on the decorated consumer class.
To Reproduce
Consider the following consumer class:
classGitHub(uplink.Consumer):
@uplink.get("/users/{username}")defget_user(self, username):
"""Get a single user."""
Create a subclass of GitHub and decorate it with any uplink decorator that should propagate to consumer methods when used as a class decorator. For this example, I apply a @response_handler that should make any consumer method return the integer 1, regardless of the actual response returned by the server:
Expected behavior
Applying a decorator to a Consumer class should propagate to ALL consumer methods available to that class, including inherited consumer methods.
Additional context
Prior to v0.3.0, the actual behavior reflected the expected behavior detailed above. However, as part of #27, we unnecessarily began restricting the application of class-level decorators to only those consumer methods defined directly on the decorated consumer class. Hence, a fix for this bug should effectively revert the changes made in #27. Notably, this means that the fix should make changes to the function uplink.helpers.get_api_definitions.
The text was updated successfully, but these errors were encountered:
Describe the bug
For consumer classes that inherit consumer methods (i.e., methods decorated with
@uplink.get
,@uplink.post
, etc.) from one or more parent classes, uplink decorators such as@response_handler
or@timeout
are not applied to those inherited methods when these decorators are used as class-level decorators. In other words, these decorators are strictly applied to consumer methods that are directly defined on the decorated consumer class.To Reproduce
Consider the following consumer class:
Create a subclass of
GitHub
and decorate it with any uplink decorator that should propagate to consumer methods when used as a class decorator. For this example, I apply a@response_handler
that should make any consumer method return the integer1
, regardless of the actual response returned by the server:Here’s a quick test that shows that the response handler is not applied to the inherited method (i.e., the assertion fails):
Expected behavior
Applying a decorator to a Consumer class should propagate to ALL consumer methods available to that class, including inherited consumer methods.
Additional context
Prior to v0.3.0, the actual behavior reflected the expected behavior detailed above. However, as part of #27, we unnecessarily began restricting the application of class-level decorators to only those consumer methods defined directly on the decorated consumer class. Hence, a fix for this bug should effectively revert the changes made in #27. Notably, this means that the fix should make changes to the function
uplink.helpers.get_api_definitions
.The text was updated successfully, but these errors were encountered: