Scope inference
#10288
Replies: 1 comment 4 replies
-
While in this trivial example it could work, what about fixtures that will return different values each time? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wrote a dependency injection system with a "scopes" system inspired by pytest: https://www.adriangb.com/di/latest/scopes/
Recently I came up with what I think is a nifty idea: automatically inferring scopes from the dependency DAG.
Picture the following:
If you run with with Pytest you get:
So you're forced to go and add
scope="session"
toget_dsn
.But in theory pytest could do this for you: it could see that no explicit scope was set for
get_dsn()
and then assign it the"session"
scope because that's the only thing it can be anyway.I imagine pytest wouldn't want to make this change and I'm not proposing it does, but I am curious what folks think of this idea, if there are any obvious issues with it, etc.
Beta Was this translation helpful? Give feedback.
All reactions