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

Priority for kwargs, or support for recursive resolve #169

Open
prefect4742 opened this issue Feb 2, 2023 · 1 comment
Open

Priority for kwargs, or support for recursive resolve #169

prefect4742 opened this issue Feb 2, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@prefect4742
Copy link

prefect4742 commented Feb 2, 2023

Two separate issues but they are related. I have classes that are nodes in a tree and I would like to be able to send in a registered entity as a parameter in kwargs when calling resolve(), like this:

class Example:
    def __init__(self, parent: 'Example', someParam: str):
        ...

parentExample = container.resolve(parent=None, someParam="Hello")
oneExample = container.resolve(parent=parentExample, someParam="world")

But as I understand the code in resolve_impl, punq will try to resolve any "needs" (registered) parameters first which would cause a loop in the __init__ code above, correct?

Is there some way to achieve this other than registering factory classes?

@bobthemighty
Copy link
Owner

Hey @prefect4742

Sorry for the delayed reply. That sounds like a sensible change. I might take a look this week and see what's involved in implementing it this way.

@bobthemighty bobthemighty added enhancement New feature or request good first issue Good for newcomers labels Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants