Skip to content

False positive "metaclass conflict" error with GenericViewSet #692

Open
@realsuayip

Description

@realsuayip

When using a custom metaclass with GenericViewSet will create "metaclass conflict" error. This seems to be due to some issue in mypy:

python/mypy#15040

GenericViewSet uses UsesQuerySet which is a Protocol, whose metaclass is ABCMeta, but during runtime type(GenericViewSet) is actually type

Using ABCMeta as base in custom metaclass fixes the issue, which is mostly fine although not entirely "correct".

I guess using protocols is more helpful than just satisfying an edge metaclass case. There seems to be some work in progress in mypy that might fix this issue, in the meantime, I wanted to open this issue here so that other people could see the cause & possible fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions