Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pylance doesn't allow a ModelSerializer to have a Meta class #689

Open
ataylor32 opened this issue Oct 31, 2024 · 0 comments
Open

Pylance doesn't allow a ModelSerializer to have a Meta class #689

ataylor32 opened this issue Oct 31, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ataylor32
Copy link

This is my code:

from rest_framework import serializers

from ..models import FAQ


class FAQSerializer(serializers.ModelSerializer):
    class Meta:
        model = FAQ
        fields = (
            "id",
            "question",
            "answer",
        )

When I open the above file in Visual Studio Code (latest version, which is 1.95.0), Meta is underlined in red. Hovering over it shows the following error:

"Meta" overrides symbol of same name in class "ModelSerializer"
  "project.faqs.api.serializers.FAQSerializer.Meta" is not assignable to "rest_framework.serializers.ModelSerializer.Meta"
  Type "type[project.faqs.api.serializers.FAQSerializer.Meta]" is not assignable to type "type[rest_framework.serializers.ModelSerializer.Meta]" Pylance(reportIncompatibleVariableOverride)
serializers.pyi(197, 11): Overridden symbol

I'm using djangorestframework-stubs==3.15.1. Am I doing something wrong?

@ataylor32 ataylor32 added the bug Something isn't working label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant