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

@inject with multiple @wraps #597

Closed
rmk135 opened this issue Jun 25, 2022 · 2 comments
Closed

@inject with multiple @wraps #597

rmk135 opened this issue Jun 25, 2022 · 2 comments
Assignees
Labels

Comments

@rmk135
Copy link
Member

rmk135 commented Jun 25, 2022

Need to check if the following behavior can be improved:

@fabiocerqueira I faced the same issue as well, adding wraps is breaking the inject.
@rmk135 could you please have a look?

My use case is similar to what Fabio mentioned:

def tagger(tag):
    def inner(func):
        # @wraps(func)  # <-- using wraps break inject
        @inject
        def tagger_wrapper(text, sep=Provide[Container.conf.sep], **kwargs):
            result = func(text, **kwargs)
            return f"{result}{sep}({tag}[{func.__name__}])"

        return tagger_wrapper

    return inner

Originally posted by @Jitesh-Khuttan in #454 (comment)

@rmk135 rmk135 changed the title @inject with @wraps @inject with multiple @wraps Jul 23, 2022
@rmk135
Copy link
Member Author

rmk135 commented Jul 23, 2022

Finally localized the issue. There is no easy fix, but potentially can be fixed with the larger refactoring.

@rmk135 rmk135 self-assigned this Jul 23, 2022
@rmk135 rmk135 added the bug label Jul 23, 2022
rmk135 added a commit that referenced this issue Jul 27, 2022
…ry and injections storage principles (#610)

* Refactor patched callables registry and injections storage principles

* Rename properties of PatchedRegistry

* Add typing improvements in wiring module

* Add __slots__ for PatchedAttribute

* Minor code style fixes

* Add test

* Rename test

* Update typing in test

* Make minor style fixes to test

* Update changelog

* Add documentation on the @Inject decorator
@rmk135
Copy link
Member Author

rmk135 commented Jul 27, 2022

Merged the fix to develop. Closing the issue, all information about releasing will go to #454

@rmk135 rmk135 closed this as completed Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant