use specific Injector instance as `inject` decorator
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
Start by tracing the existing inject decorator and Injector behavior, then compare them with the container.get workaround described here. Done means the project has a decided API for selecting a specific Injector instance at decoration time and clearly defined behavior for modules with different dependency configurations.
Written by the indexing model from the issue text.
Description
This has been in my mind for some time so I decided to finally write it.
Would that be possible to specify the Injector instance that should be used to inject dependencies? I see it the following way
container = Injector([module])
...
@container.inject # or maybe @inject(container)
def do_something(a: Dependency):
...
My motivation is that I have multiple python modules, each one configuring it's own dependencies so each module (in general) expects different instances of dependencies.
I know that the proposed solution requires a variable container to be defined at interpretation time but not always is that undesireable. What do you think?
My workaround currently is calling container.get but I don't really like it.
Or is there something I don't understand about how injector works and inject chooses "the most local" container?
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-injector/injector
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
python-injector/injector#317 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
python-injector/injector#298 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
python-injector/injector#297 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
python-injector/injector#267 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
python-injector/injector#258 · 3 comments ·
All issues in python-injector/injector
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
zostera/django-bootstrap4#894 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3276 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
zilliztech/memsearch#759 ·