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

Cannot access member "id" for type "AbstractBaseUser" using pyright

Open powelleric opened this issue 2 years ago • 1 comments

I have a custom user model that inherits from AbstractBaseUser, but when I do something like request.user.id, pyright thinks that user is of type AbstractBaseUser (instead of my class MyUser) and it can't find the id property (or any other properties).

My custom User class is specified in my Django settings: AUTH_USER_MODEL = 'userauth.MyUser'.

I notice Mypy is aware of Django settings. Is pyright not equipped to do that or am I doing something else wrong?

powelleric avatar Jul 18 '22 17:07 powelleric

Look it here: https://github.com/typeddjango/djangorestframework-stubs/issues/147 or here https://github.com/typeddjango/django-stubs#how-can-i-create-a-httprequest-thats-guaranteed-to-have-an-authenticated-user

Skorpyon avatar Nov 13 '23 16:11 Skorpyon