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

Use decorator module for signature-preserving decorators #212

Closed
OOPMan opened this issue May 4, 2017 · 4 comments
Closed

Use decorator module for signature-preserving decorators #212

OOPMan opened this issue May 4, 2017 · 4 comments

Comments

@OOPMan
Copy link

OOPMan commented May 4, 2017

It looks like your awesome cached and multi_cached decorators don't make use of https://pypi.python.org/pypi/decorator which helpers write cleaner decorators that benefit from signature-preservation (which is important to some people :-)

I could submit a PR if you like?

@argaen
Copy link
Member

argaen commented May 4, 2017

Hi @OOPMan, do you have an example use case, if possible I would prefer to use https://docs.python.org/3/library/functools.html#functools.wraps rather than adding a new dependency :)

@OOPMan
Copy link
Author

OOPMan commented May 4, 2017

@argaen I believe you can achieve the same with wraps (In fact, I think decorator does use wrap to some extent) but there's more work involved.

Honestly, I wouldn't consider this a high priority, it's just something I've run into now and then with certain code trying to implement the concept of interfaces in Python and checking that functions conform to the interface (IIRC, this is a thing in the Zope part of the Python world). When you decorate such a function in a non-signature preserving way the interface nonsense complains because a function which was a(b,c,d,e) is now a(*args, **kwargs)

It's really rather silly :-)

@argaen
Copy link
Member

argaen commented May 4, 2017

I'm happy to add the functools.wraps part. Once I have the MR I can ping you to see if there is anything you are missing :)

@OOPMan
Copy link
Author

OOPMan commented May 5, 2017

@argaen Sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants