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 61e7f1b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django-stubs/contrib/auth/base_user.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Literal, TypeVar, overload
from typing import Any, ClassVar, Literal, TypeVar, overload

from django.db import models
from django.db.models.base import Model
Expand All @@ -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 61e7f1b

Please sign in to comment.