Closed attilavetesi-epam closed 5 months ago
Hi @attilavetesi-epam, thank you for the first issue. You are right, and I was thinking of doing that since I encountered the same issue in a project when using non-strict mode. Unfortunately, I'll be back in 10 days from vacation and will add this. Meanwhile, you can use scope decorators.
Available in 0.23.0
The code at: https://github.com/antonrh/anydi/blob/17154b88231cc339fe118afa1ab2ebadbbde6681/anydi/_container.py#L396 defaults to scope
None
when there are no sub-dependencies with defined scopes.This (as far as I understand) enforces that a scope decorator or manual registration is always mandatory on types, otherwise automatic registration cannot happen, which (I think) invalidates a bit the automatic registration itself for types that do not have any sub-dependencies (i.e. they can be injected by themselves).
Would it be possible to default to a scope (e.g. transient) thus making automatic registration more seamless?