diff --git a/.mypy-baseline.txt b/.mypy-baseline.txt index 4e7114dff..1442a4813 100644 --- a/.mypy-baseline.txt +++ b/.mypy-baseline.txt @@ -2026,11 +2026,6 @@ src/paperless/serialisers.py:0: error: Function is missing a type annotation [n src/paperless/serialisers.py:0: error: Function is missing a type annotation [no-untyped-def] src/paperless/serialisers.py:0: error: Function is missing a type annotation for one or more parameters [no-untyped-def] src/paperless/serialisers.py:0: error: Item "None" of "str | None" has no attribute "replace" [union-attr] -src/paperless/serialisers.py:0: error: Missing type arguments for generic type "ModelSerializer" [type-arg] -src/paperless/serialisers.py:0: error: Missing type arguments for generic type "ModelSerializer" [type-arg] -src/paperless/serialisers.py:0: error: Missing type arguments for generic type "ModelSerializer" [type-arg] -src/paperless/serialisers.py:0: error: Missing type arguments for generic type "ModelSerializer" [type-arg] -src/paperless/serialisers.py:0: error: Missing type arguments for generic type "ModelSerializer" [type-arg] src/paperless/serialisers.py:0: error: Need type annotation for "auth_token" [var-annotated] src/paperless/serialisers.py:0: error: Signature of "run_validation" incompatible with supertype "rest_framework.fields.Field" [override] src/paperless/serialisers.py:0: error: Skipping analyzing "allauth.mfa.adapter": module is installed, but missing library stubs or py.typed marker [import-untyped] @@ -2518,7 +2513,6 @@ src/paperless_mail/serialisers.py:0: error: Function is missing a type annotatio src/paperless_mail/serialisers.py:0: error: Function is missing a type annotation [no-untyped-def] src/paperless_mail/serialisers.py:0: error: Function is missing a type annotation [no-untyped-def] src/paperless_mail/serialisers.py:0: error: Function is missing a type annotation for one or more parameters [no-untyped-def] -src/paperless_mail/serialisers.py:0: error: Missing type arguments for generic type "PrimaryKeyRelatedField" [type-arg] src/paperless_mail/tests/test_mail.py:0: error: "BogusFolderManager" has no attribute "list" [attr-defined] src/paperless_mail/tests/test_mail.py:0: error: "BogusFolderManager" has no attribute "list" [attr-defined] src/paperless_mail/tests/test_mail.py:0: error: "BogusFolderManager" has no attribute "list" [attr-defined] diff --git a/.pyrefly-baseline.json b/.pyrefly-baseline.json index 4845977dd..f3f6a0a5b 100644 --- a/.pyrefly-baseline.json +++ b/.pyrefly-baseline.json @@ -2245,9 +2245,9 @@ "severity": "error" }, { - "line": 2894, + "line": 2896, "column": 11, - "stop_line": 2894, + "stop_line": 2896, "stop_column": 15, "path": "src/documents/serialisers.py", "code": -2, @@ -2257,9 +2257,9 @@ "severity": "error" }, { - "line": 2917, + "line": 2919, "column": 11, - "stop_line": 2917, + "stop_line": 2919, "stop_column": 15, "path": "src/documents/serialisers.py", "code": -2, @@ -2269,9 +2269,9 @@ "severity": "error" }, { - "line": 3036, + "line": 3038, "column": 11, - "stop_line": 3036, + "stop_line": 3038, "stop_column": 15, "path": "src/documents/serialisers.py", "code": -2, @@ -2281,9 +2281,9 @@ "severity": "error" }, { - "line": 3218, + "line": 3220, "column": 16, - "stop_line": 3218, + "stop_line": 3220, "stop_column": 33, "path": "src/documents/serialisers.py", "code": -2, @@ -2293,9 +2293,9 @@ "severity": "error" }, { - "line": 3222, + "line": 3224, "column": 16, - "stop_line": 3222, + "stop_line": 3224, "stop_column": 32, "path": "src/documents/serialisers.py", "code": -2, @@ -2305,9 +2305,9 @@ "severity": "error" }, { - "line": 3237, + "line": 3239, "column": 52, - "stop_line": 3237, + "stop_line": 3239, "stop_column": 60, "path": "src/documents/serialisers.py", "code": -2, @@ -2317,9 +2317,9 @@ "severity": "error" }, { - "line": 3237, + "line": 3239, "column": 62, - "stop_line": 3237, + "stop_line": 3239, "stop_column": 69, "path": "src/documents/serialisers.py", "code": -2, @@ -12565,9 +12565,9 @@ "severity": "error" }, { - "line": 220, + "line": 222, "column": 9, - "stop_line": 220, + "stop_line": 222, "stop_column": 23, "path": "src/paperless/serialisers.py", "code": -2, @@ -12577,9 +12577,9 @@ "severity": "error" }, { - "line": 249, + "line": 251, "column": 28, - "stop_line": 249, + "stop_line": 251, "stop_column": 43, "path": "src/paperless/serialisers.py", "code": -2, @@ -12589,9 +12589,9 @@ "severity": "error" }, { - "line": 292, + "line": 294, "column": 11, - "stop_line": 292, + "stop_line": 294, "stop_column": 15, "path": "src/paperless/serialisers.py", "code": -2, diff --git a/src/paperless/serialisers.py b/src/paperless/serialisers.py index 00a1c0f41..92676df4e 100644 --- a/src/paperless/serialisers.py +++ b/src/paperless/serialisers.py @@ -74,7 +74,7 @@ class PaperlessAuthTokenSerializer(AuthTokenSerializer): return attrs -class UserSerializer(PasswordValidationMixin, serializers.ModelSerializer): +class UserSerializer(PasswordValidationMixin, serializers.ModelSerializer[User]): password = ObfuscatedPasswordField(required=False) user_permissions = serializers.SlugRelatedField( many=True, @@ -142,7 +142,7 @@ class UserSerializer(PasswordValidationMixin, serializers.ModelSerializer): return user -class GroupSerializer(serializers.ModelSerializer): +class GroupSerializer(serializers.ModelSerializer[Group]): permissions = serializers.SlugRelatedField( many=True, queryset=Permission.objects.exclude(content_type__app_label="admin"), @@ -158,7 +158,7 @@ class GroupSerializer(serializers.ModelSerializer): ) -class SocialAccountSerializer(serializers.ModelSerializer): +class SocialAccountSerializer(serializers.ModelSerializer[SocialAccount]): name = serializers.SerializerMethodField() class Meta: @@ -176,7 +176,7 @@ class SocialAccountSerializer(serializers.ModelSerializer): return "Unknown App" -class ProfileSerializer(PasswordValidationMixin, serializers.ModelSerializer): +class ProfileSerializer(PasswordValidationMixin, serializers.ModelSerializer[User]): email = serializers.EmailField(allow_blank=True, required=False) password = ObfuscatedPasswordField(required=False, allow_null=False) auth_token = serializers.SlugRelatedField(read_only=True, slug_field="key") @@ -209,7 +209,9 @@ class ProfileSerializer(PasswordValidationMixin, serializers.ModelSerializer): ) -class ApplicationConfigurationSerializer(serializers.ModelSerializer): +class ApplicationConfigurationSerializer( + serializers.ModelSerializer[ApplicationConfiguration], +): user_args = serializers.JSONField(binary=True, allow_null=True) barcode_tag_mapping = serializers.JSONField(binary=True, allow_null=True) llm_api_key = ObfuscatedPasswordField( diff --git a/src/paperless_mail/serialisers.py b/src/paperless_mail/serialisers.py index 77c6c70f8..a4c3c5830 100644 --- a/src/paperless_mail/serialisers.py +++ b/src/paperless_mail/serialisers.py @@ -57,7 +57,7 @@ class MailAccountSerializer(OwnedObjectSerializer): return instance -class AccountField(serializers.PrimaryKeyRelatedField): +class AccountField(serializers.PrimaryKeyRelatedField[MailAccount]): def get_queryset(self): return MailAccount.objects.all().order_by("-id")