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

Decorators support introspection #213

Merged
merged 1 commit into from
May 6, 2017

Conversation

argaen
Copy link
Member

@argaen argaen commented May 6, 2017

Closes #212

@codecov-io
Copy link

codecov-io commented May 6, 2017

Codecov Report

Merging #213 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #213      +/-   ##
==========================================
+ Coverage   98.92%   98.92%   +<.01%     
==========================================
  Files          12       12              
  Lines         651      652       +1     
  Branches       74       74              
==========================================
+ Hits          644      645       +1     
  Misses          7        7
Impacted Files Coverage Δ
aiocache/decorators.py 100% <100%> (ø) ⬆️

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 0d19917...875d11f. Read the comment docs.


assert what.__name__ == "what"
assert str(inspect.signature(what)) == '(self, a, b)'
assert inspect.getfullargspec(what.__wrapped__).args == ['self', 'a', 'b']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OOPMan have a look at the behavior here. Dunno how zope does the interface check, but it should use the signature (https://docs.python.org/3/library/inspect.html#inspect.signature) one since it enables the follow_wrapper by default.

getfullargspec (https://docs.python.org/3/library/inspect.html#inspect.getfullargspec) doesn't support following the wrapped attribute that functools.wraps adds.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Iirc Zope uses inspect as you have since it's the only sane way to do it. There are probably some insane ways but why worry about those :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, my point was more that if Zope uses inspect.signature then it will work. If it uses inspect.getfullargspec it won't because the real signature is under the __wrapped__ attribute of the function and getfullargspec doesn't use it (while signature does :))

@argaen argaen merged commit be015bf into master May 6, 2017
@argaen argaen deleted the enhancement_#212/improve_decorators_introspection branch May 6, 2017 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants