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
Introduced in #2335, _UserModel type alias is resolved by plugin to point to current AUTH_USER_MODEL.
This functionality is extremely helpful in certain circumstances, esp. when typing django-related packages. I was trying to improve type hints of djangorestframework-simplejwt and noticed that it'd be very convenient to use this _UserModel alias to spell "type of current user model".
For example, this will help me annotate the authentication class correctly: it calls get_user_model internally, assigning returned class to an instance variable. Annotating with _UserModel would greatly improve usability compared to AbstractBaseUser.
I propose to add an alias to django_stubs_ext resolved in the same way as _UserModel.
I'm willing to open a PR with this change if that sounds reasonable.
The text was updated successfully, but these errors were encountered:
sterliakov
changed the title
[FR] Make _django.contrib.auth.base_user._UserModel part of a public API
[FR] Make django.contrib.auth.base_user._UserModel part of a public API
Sep 10, 2024
Introduced in #2335,
_UserModel
type alias is resolved by plugin to point to currentAUTH_USER_MODEL
.This functionality is extremely helpful in certain circumstances, esp. when typing django-related packages. I was trying to improve type hints of djangorestframework-simplejwt and noticed that it'd be very convenient to use this
_UserModel
alias to spell "type of current user model".For example, this will help me annotate the authentication class correctly: it calls
get_user_model
internally, assigning returned class to an instance variable. Annotating with_UserModel
would greatly improve usability compared toAbstractBaseUser
.I propose to add an alias to
django_stubs_ext
resolved in the same way as_UserModel
.I'm willing to open a PR with this change if that sounds reasonable.
The text was updated successfully, but these errors were encountered: