typeddjango / djangorestframework-stubs

PEP-484 stubs for django-rest-framework
MIT License
452 stars 118 forks source link

New mypy failures on `djangorestframework-stubs` after `django-stubs` update #650

Closed sobolevn closed 3 months ago

sobolevn commented 3 months ago

Run mypy --cache-dir=/dev/null --no-incremental rest_framework-stubs
rest_framework-stubs/authtoken/models.pyi:16: error: Name "pk" already defined (possibly by an import)
rest_framework-stubs/authtoken/models.pyi:17: error: Cannot override writeable attribute with read-only property
rest_framework-stubs/request.pyi:71: error: Signature of "user" incompatible with supertype "HttpRequest"
rest_framework-stubs/request.pyi:71: note:      Superclass:
rest_framework-stubs/request.pyi:71: note:          Union[User, AnonymousUser]
rest_framework-stubs/request.pyi:71: note:      Subclass:
rest_framework-stubs/request.pyi:71: note:          Union[AbstractBaseUser, AnonymousUser]
Found 3 errors in 2 files (checked 68 source files)

cc @flaeppe

Looks like that it fails because of our recent User plugin change.

flaeppe commented 3 months ago

Right, yeah, we probably want use the same type of setup here as in django-stubs. I think it'll work to just import and use django.contrib.auth.base_user._UserModel.

I suppose any kind of third party working with the configured user would like to benefit from what we declared as _UserModel, so there might also be a use case to move it to django-stubs-ext and import from there.