Advertisement
Guest User

Untitled

a guest
Jan 26th, 2021
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.67 KB | None | 0 0
  1. # модель пользователя / models.py
  2.  
  3. class User(AbstractUser):
  4.     username = None
  5.     first_name = None
  6.     last_name = None
  7.     email = models.EmailField(unique=True)
  8.  
  9.     USERNAME_FIELD = 'email'
  10.     REQUIRED_FIELDS = []
  11.  
  12.     objects = CustomUserManager()
  13.  
  14.     def __str__(self):
  15.         return f'{self.email}, #{self.id}'
  16.  
  17.     class Meta:
  18.         ordering = ['-id']
  19.  
  20.  
  21. # настройки mypy / setup.cfg
  22.  
  23. [mypy]
  24. plugins =
  25.     mypy_django_plugin.main
  26.  
  27. ignore_missing_imports = True
  28. implicit_reexport = False
  29. strict_optional = True
  30. strict_equality = True
  31. no_implicit_optional = True
  32. warn_unused_ignores = True
  33. warn_redundant_casts = True
  34. warn_unused_configs = True
  35. warn_unreachable = True
  36. warn_no_return = True
  37.  
  38. [mypy.plugins.django-stubs]
  39. django_settings_module = feeder.settings
  40.  
  41.  
  42. # трейсбек
  43.  
  44. user/models.py:32: error: Incompatible types in assignment (expression has type "None", base class "AbstractUser" defined the type as "CharField[Union[str, int, Combinable], str]")
  45. user/models.py:33: error: Incompatible types in assignment (expression has type "None", base class "AbstractUser" defined the type as "CharField[Union[str, int, Combinable], str]")
  46. user/models.py:34: error: Incompatible types in assignment (expression has type "None", base class "AbstractUser" defined the type as "CharField[Union[str, int, Combinable], str]")
  47. user/models.py:38: error: Need type annotation for 'REQUIRED_FIELDS' (hint: "REQUIRED_FIELDS: List[<type>] = ...")
  48. user/models.py:40: error: Incompatible types in assignment (expression has type "CustomUserManager[User]", base class "AbstractUser" defined the type as "UserManager[AbstractUser]")
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement