djangorestframework-stubs
djangorestframework-stubs copied to clipboard
TypeError: 'type' object is not subscriptable
Bug report
What's wrong
class Foo(serializers.PrimaryKeyRelatedField[FooModel]): ...
serializers.PrimaryKeyRelatedField[FooModel]
TypeError: 'type' object is not subscriptable
How is that should be
Success: no issues found in 1 source file
System information
- OS:
Linux f16759b1b324 5.10.104-linuxkit #1 SMP PREEMPT Thu Mar 17 17:05:54 UTC 2022 aarch64 GNU/Linux pythonversion: 3.10.6djangoversion: 4.0.7mypyversion: 0.961django-stubsversion: 1.12.0
Also, it isn't asked for by the template, but:
djangorestframeworkversion: 3.13.1djangorestframework-stubsversion: 1.7.0
I've seen some open issues about similar problems, but:
- This doesn't affect other classes, only
PrimaryKeyRelatedField - The usual suggestion is "upgrade to 3.12+" and I'm on 3.13.
I think this is an unexpected defect, but please let me know if I've just misunderstood the other issues.
Hope this helps https://github.com/typeddjango/djangorestframework-stubs/issues/255#issuecomment-1320496964