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"]
|
linting = ["black", "isort", "flake8", "bandit"]
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
|
strict = true
|
||||||
disable_error_code = ["no-redef", "import-untyped"]
|
disable_error_code = ["no-redef", "import-untyped"]
|
||||||
exclude = ["*/migrations/*"]
|
exclude = ["*/migrations/*"]
|
||||||
plugins = ["mypy_django_plugin.main", "mypy_drf_plugin.main"]
|
plugins = ["mypy_django_plugin.main", "mypy_drf_plugin.main"]
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ from rest_framework.fields import (
|
||||||
EmailField,
|
EmailField,
|
||||||
ListField,
|
ListField,
|
||||||
SerializerMethodField,
|
SerializerMethodField,
|
||||||
|
JSONField,
|
||||||
)
|
)
|
||||||
from rest_framework.serializers import ModelSerializer, Serializer
|
from rest_framework.serializers import ModelSerializer, Serializer
|
||||||
from rest_framework_simplejwt.exceptions import TokenError
|
from rest_framework_simplejwt.exceptions import TokenError
|
||||||
|
|
@ -38,6 +39,7 @@ class UserSerializer(ModelSerializer):
|
||||||
password = CharField(write_only=True, required=False)
|
password = CharField(write_only=True, required=False)
|
||||||
is_staff = BooleanField(read_only=True)
|
is_staff = BooleanField(read_only=True)
|
||||||
recently_viewed = SerializerMethodField(required=False, read_only=True)
|
recently_viewed = SerializerMethodField(required=False, read_only=True)
|
||||||
|
attributes = JSONField(required=False)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_avatar_url(obj) -> str:
|
def get_avatar_url(obj) -> str:
|
||||||
|
|
@ -53,6 +55,7 @@ class UserSerializer(ModelSerializer):
|
||||||
"avatar_url",
|
"avatar_url",
|
||||||
"is_staff",
|
"is_staff",
|
||||||
"recently_viewed",
|
"recently_viewed",
|
||||||
|
"attributes",
|
||||||
"first_name",
|
"first_name",
|
||||||
"last_name",
|
"last_name",
|
||||||
"password",
|
"password",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue