Closed rschyboll closed 2 years ago
Hello! Thanks for the bug report and happy you like it. :)
It's indeed the is_optional
check that fails with List[str]
. I've replaced it with a check is type(None)
instead, the goal is only to detect Optional[T]
arguments for inject.me()
. Pushing a fix currently. I will close the issue once published!
Fixed with 1.4.2
By the way, by_default
is not necessary in your example. The goal of @implements(...).by_default
is to have a default implementation that is used when no implementation can be provided. Either because there is simply none at all or because none matches the constraints on the predicates (more advanced use of @interface
).
So @implements(...)
is enough most of the time unless you want somebody else to be able to override easily a default implementation that you defined.
The documentation needs some rework on those topics. ^^
And if you have any comments on the library, I'd love to hear them!
Thanks!
Just tested it, the fix seems to be working.
And thanks for the tip, I misunderstood how by_default
actually works, need to change that in my project.
I do have one question, but I'm going to open a new issue for it ^^
Hi, first i just wanted to say that i really like antidote, a really refreshing take on DI in Python :D
I encountered today an error, when defining an interface, and its implementation, with a method that has a parameter that consists of a union of a subscripted generic (like
list[str]
), it throws the following error:I created a simple reproducible example that shows that error:
It seems that the library is calling a
isinstance
check on thelist[str]
type in theis_optional
method, so there might be required a check, if that type is a generic type, maybe with aget_args
call?