Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop sharing class decorators across siblings #152

Merged
merged 2 commits into from
Mar 26, 2019

Conversation

prkumar
Copy link
Owner

@prkumar prkumar commented Mar 19, 2019

I noticed that, when writing a superclass that is extended by two separate subclasses, class-level decorators are shared across the siblings. You can reproduce this issue with the following example:

class GitHub(Consumer):
    @get("users/{id}")
    def get(self, id):
        pass

@response_handler(lambda _: 2)
class GitHub2(GitHub):
    pass


@response_handler(lambda x: x.json())
class GitHub3(GitHub):
    pass


print(GitHub2("https://api.github.com").get_user("prkumar"))
print(GitHub3("https://api.github.com").get_user("prkumar"))

Running the above code snippet, you'll notice that the first invocation will throw an AttributeError since the response is wrapped by both lambda _: 2 and lambda x: x.json(); notably, the latter handler receives and int (i.e., 2) as it's input, which doesn't have a json method.

@prkumar prkumar added the Bug label Mar 20, 2019
@prkumar prkumar added this to the v0.9.0 milestone Mar 20, 2019
@codecov
Copy link

codecov bot commented Mar 26, 2019

Codecov Report

Merging #152 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #152   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          41     41           
  Lines        2084   2110   +26     
  Branches      167    176    +9     
=====================================
+ Hits         2084   2110   +26
Impacted Files Coverage Δ
uplink/arguments.py 100% <100%> (ø) ⬆️
uplink/decorators.py 100% <100%> (ø) ⬆️
uplink/builder.py 100% <100%> (ø) ⬆️
uplink/commands.py 100% <100%> (ø) ⬆️
uplink/retry/retry.py 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db502bc...a85d23a. Read the comment docs.

@prkumar prkumar merged commit 592757c into master Mar 26, 2019
@prkumar prkumar deleted the v0.9.0/fix-class-decorators branch March 27, 2019 23:31
@prkumar prkumar mentioned this pull request Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant