You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Overriding does not work with non-primitive type objects in Litestar #122
I found a new test case. This is more of a Litestar problem, but still
Non-primitive objects cannot be overridden with any other type until we mark it with the Any annotation. Below is the code that will help reproduce this
@get(path="mock_overriding", dependencies={"some_service": Provide(DIContainer.some_service)})# does not works with some_service: SomeService type, but works with some_service: SomeService | Anyasyncdefmock_overriding_endpoint_handler(self, some_service: SomeService) ->dict[str, typing.Any]:
return {"object": some_service.do_smth()}
Activity
lesnik512 commentedon Nov 19, 2024
@nightblure Found another hack here litestar-org/litestar#2597 (comment)
Can be fixed by adding
Dependency(skip_validation=True)like this:I think we need to document this behaviour and that's it. What do you think?
nightblure commentedon Nov 19, 2024
@lesnik512
It doesn't look that convenient, but it's good that it works
I can add this to the documentation with examples and tests
lesnik512 commentedon Nov 19, 2024
@nightblure would be great 👍