Pylance "unreachable code" on ModelViewSet's get_queryset and get_object methods (and those using them) #9868
Unanswered
the-middium
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
After coming back to a project that uses DRF, after a while, I've noticed that Pylance marks
ModelViewSet's.get_object(...)method as being-> NoReturn. After checking, it seems thatGenericAPIView.querysetbeing set toNoneis causing Pylance to think that the non-Noneassertion in.get_queryset(...)is triggered and that the code stops there (that method is marked by Pylance as returningNever).After adding the type annotation
QuerySet | Noneto.queryset, these issues appear to have been resolved.Beta Was this translation helpful? Give feedback.
All reactions