djangorestframework-stubs icon indicating copy to clipboard operation
djangorestframework-stubs copied to clipboard

TypeError: 'type' object is not subscriptable

Open christianbundy opened this issue 3 years ago • 2 comments

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
  • python version: 3.10.6
  • django version: 4.0.7
  • mypy version: 0.961
  • django-stubs version: 1.12.0

Also, it isn't asked for by the template, but:

  • djangorestframework version: 3.13.1
  • djangorestframework-stubs version: 1.7.0

christianbundy avatar Sep 27 '22 02:09 christianbundy

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.

christianbundy avatar Sep 27 '22 02:09 christianbundy

Hope this helps https://github.com/typeddjango/djangorestframework-stubs/issues/255#issuecomment-1320496964

monosans avatar Nov 19 '22 06:11 monosans