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

Add InjectorConfig to control explicit injection behavior #85

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonathanmach
Copy link

@jonathanmach jonathanmach commented Nov 18, 2024

@jstasiak, just raising this to get some initial thoughts from you (before I continue making progress on this).

I imagined that #83 could be implemented via something like:

FlaskInjector(app=app, modules=[setup_di], inject_explicit_only=True)  # where inject_explicit_only: If set to True, only inject parameters explicitly marked with Inject[SomeType].

I also introduced a InjectorConfig object that gets passed around. I decided to go with a proper class instead of a flag in case you need to introduce additional config params in the future.
(alternatively I could've made wrap_fun() a method of FlaskInjector? And keep InjectorConfig as a state in FlaskInjector )

I'm keen to hear if you'd prefer it implemented in a different way. Let me know!

@@ -39,6 +39,13 @@
T = TypeVar('T', LocalProxy, Callable)


class InjectorConfig:
Copy link
Author

Choose a reason for hiding this comment

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

Alternatively we could use a dataclass

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