Skip to content

Commit

Permalink
AbstractBaseUser.REQUIRED_FIELDS is a ClassVar
Browse files Browse the repository at this point in the history
On a subclass, there's not correct way to annotate `REQUIRED_FIELDS`.

- Annotating as `list[str]` warns that this should be annotated as
  `ClassVar`.
- Annotating as `ClassVar` warns that the this doesn't match the parent
  class.

This field is a class variable anyway, so this is the correct annotation.
  • Loading branch information
WhyNotHugo committed Sep 26, 2023
1 parent b5482a4 commit 36f5061
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion django-stubs/contrib/auth/base_user.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BaseUserManager(models.Manager[_T]):
def get_by_natural_key(self, username: str | None) -> _T: ...

class AbstractBaseUser(models.Model):
REQUIRED_FIELDS: list[str]
REQUIRED_FIELDS: ClassVar[list[str]]

password = models.CharField(max_length=128)
last_login = models.DateTimeField(blank=True, null=True)
Expand Down

0 comments on commit 36f5061

Please sign in to comment.