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
Describe the bug
This is typing issue, not affecting anyhow the execution of code.
When we override the AutoSchema and provide it proper types, then we get some inconsistency between what DRF-stubs returns and what drf-spectacular expects
To Reproduce
The example is from blueprints of RW Serialziers:
classRWAutoSchema(openapi.AutoSchema):
@typing_extensions.overridedefget_request_serializer(self) ->drf_serializers.BaseSerializer[_Mo_co]: # <-- this is what caused issues as Spectacular expects `Serializer | type[Serializer] | None` when DRF-stubs return it as `BaseSerializer`ifisinstance(self.view, drf_rw_serializers_generics.GenericAPIView):
returnself.view.get_write_serializer()
returnt.cast(drf_serializers.BaseSerializer[_Mo_co], self._get_serializer()) # <-- need cast here as `_get_serializer` is untyped@typing_extensions.overridedefget_response_serializers(self) ->drf_serializers.BaseSerializer[_Mo_co]: # <-- this is what caused issues as Spectacular expects `Serializer | type[Serializer] | None` when DRF-stubs return it as `BaseSerializer`ifisinstance(self.view, drf_rw_serializers_generics.GenericAPIView):
returnself.view.get_read_serializer()
returnt.cast(drf_serializers.BaseSerializer[_Mo_co], self._get_serializer()) # <-- need cast here as `_get_serializer` is untyped
Expected behavior
There should not be typing errors, maybe something should be updated on DRF-stubs side?
Describe the bug
This is typing issue, not affecting anyhow the execution of code.
When we override the AutoSchema and provide it proper types, then we get some inconsistency between what DRF-stubs returns and what
drf-spectacular
expectsTo Reproduce
The example is from blueprints of RW Serialziers:
Expected behavior
There should not be typing errors, maybe something should be updated on DRF-stubs side?
The link for stubs file: https://github.com/typeddjango/djangorestframework-stubs/blob/master/rest_framework-stubs/generics.pyi#L34
The text was updated successfully, but these errors were encountered: