Skip to content

Optional call for decorators #103

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

Merged
merged 11 commits into from
Sep 9, 2020

Conversation

altendky
Copy link
Member

@altendky altendky commented May 14, 2020

I give in...

Draft for:

@altendky altendky changed the title [WIP] Optional call for decorators Optional call for decorators Jun 11, 2020
@altendky
Copy link
Member Author

@cdunklau, since you want this care to offer any opinions? I feel like decorator should either already have it or help out with it but...

Comment on lines +145 to +170
def _optional_arguments():
def decorator_decorator(d):
# TODO: this should get the signature of d minus the f or something
def decorator_wrapper(*args, **decorator_arguments):
"""this is decorator_wrapper"""
if len(args) > 1:
raise positional_not_allowed_exception()

if len(args) == 1:
maybe_f = args[0]

if len(decorator_arguments) > 0 or not callable(maybe_f):
raise positional_not_allowed_exception()

f = maybe_f
return d(f)

# TODO: this should get the signature of d minus the kwargs
def decorator_closure_on_arguments(f):
return d(f, **decorator_arguments)

return decorator_closure_on_arguments

return decorator_wrapper

return decorator_decorator
Copy link
Member Author

@altendky altendky Jul 28, 2020

Choose a reason for hiding this comment

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

This is basically just @decorator.decorator...

altendky/qtrio#105

@altendky altendky marked this pull request as draft July 28, 2020 00:08
@altendky altendky marked this pull request as ready for review September 9, 2020 18:00
@altendky altendky merged commit 3687f39 into pytest-dev:master Sep 9, 2020
@altendky altendky deleted the optional_call_for_decorators branch September 9, 2020 18:00
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.

1 participant