-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Should None be an allowed factory return value? #22
Comments
Noe that's not what it means. |
Let's say a user has set up a factory that explicitely returns Now, what I said before about closing logic was erroneous, since all generators are added to the |
But what would None mean? Should we raise an exception if a factory returns None? Aren't you overarchingly asking for #12? |
That's the thing. I don't think it should be up to the library (ie. |
ah now I got it 😅 currently we're being kinda smart – yeah we should fix that |
fix is in 23.11! |
Great ^^ |
currently,
Container.get
starts with the followingmeaning that if a factory has been run, and returns
None
, this value is not considered cached when requesting it the next time and the factory will be run again, overriding any potential closing logic.I could imagine a user wanting to do something along the lines of:
I'm not sure exactly what a use case for this might be, but the current implementation disallows the user to have None be a meaningful value which is generally considered not a good practice for a library. And it's easy to fix by just substituting the first dictionary lookup default value by a sentinel
The text was updated successfully, but these errors were encountered: