Suggestion for better usage
Closed this issue · 4 comments
I really like this project.
I always put this on the top of dependency list for Python project.
The coverage of this lib: all Python Object, flexible use case and customizable are fascinating.
But there is lack of guard, and I have learned how to handle it by suffering.
I think this might helpful,
-
Guaranteed Correct DI attr on bootstrap:
1.1. Check Literal str Injection if attr is exist.
1.2. Check wiring missed Provide[...]
1.3. Checking provider args. -
Reliable Container Initializing:
I have written code initializing container 2 times. Cause was wiring including container initializing. But there was no sign, just side effect. I hardly found that after some problem.
Thanks for your effort.
In v4.48.2 I've added warn_unresolved=True flag to wire/WiringConfiguration (see docs). It won't crash nor prevent you from doing typos, but still should help with debugging (make sure to run with -Walways).
As of pt.2, try using auto_wire=False in WiringConfiguration: docs
Otherwise, being more strict and explicit about issues you mentioned would be a breaking change, so proper fix will likely be in the next major version.
Great!
I truly appreciate your support.
@ZipFile
I do not understand
(make sure to run with
-Walways)
Would you explain what is -Walways ?
python -Walways ...
There are other ways to enable all the warnings, see warning control docs for details. By default Python will print single warning only once, but we're interested in all its occurrences.
Ah I got it, -W always.
Thanks for your help!