Features: 1) Enable strict mode in mypy for stricter type checking; 2) Add attributes field to serializer with JSONField;
Fixes: None; Extra: 1) Update imports in `serializers.py` to include `JSONField`;
This commit is contained in:
parent
954e02385c
commit
5ae198911b
2 changed files with 4 additions and 0 deletions
|
|
@ -103,6 +103,7 @@ testing = ["pytest", "pytest-django", "coverage"]
|
|||
linting = ["black", "isort", "flake8", "bandit"]
|
||||
|
||||
[tool.mypy]
|
||||
strict = true
|
||||
disable_error_code = ["no-redef", "import-untyped"]
|
||||
exclude = ["*/migrations/*"]
|
||||
plugins = ["mypy_django_plugin.main", "mypy_drf_plugin.main"]
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from rest_framework.fields import (
|
|||
EmailField,
|
||||
ListField,
|
||||
SerializerMethodField,
|
||||
JSONField,
|
||||
)
|
||||
from rest_framework.serializers import ModelSerializer, Serializer
|
||||
from rest_framework_simplejwt.exceptions import TokenError
|
||||
|
|
@ -38,6 +39,7 @@ class UserSerializer(ModelSerializer):
|
|||
password = CharField(write_only=True, required=False)
|
||||
is_staff = BooleanField(read_only=True)
|
||||
recently_viewed = SerializerMethodField(required=False, read_only=True)
|
||||
attributes = JSONField(required=False)
|
||||
|
||||
@staticmethod
|
||||
def get_avatar_url(obj) -> str:
|
||||
|
|
@ -53,6 +55,7 @@ class UserSerializer(ModelSerializer):
|
|||
"avatar_url",
|
||||
"is_staff",
|
||||
"recently_viewed",
|
||||
"attributes",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"password",
|
||||
|
|
|
|||
Loading…
Reference in a new issue