-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Metaclass conflict error when base class uses an imported metaclass with no annotation #14182
Comments
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
Fix hundreds of errors reported by mypy since 0.990, e.g.: ``` lib/galaxy/model/__init__.py:9626: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc] class CleanupEventLibraryAssociation(Base): ^ ``` It should be possible to revert this workaround once python/mypy#14182 is fixed.
For anyone else that wanders through here because they are getting As mentioned in the description on this issue, I was getting the error when defining a custom Permission for Django Rest Framework. That eventually led me to find a solved issue on djangorestframework-stubs typeddjango/djangorestframework-stubs#280. So in my case, although I couldn't see the conflict looking at the drf source code, it instead existed in the stub where there was an additional mypy playground reproducing the specific red herring: https://mypy-play.net/?mypy=0.990&python=3.11&gist=bf79ced1e7ed3fa71a869056e8d42f8b |
Here's a similar problem. Not if it's related. In this case, inheriting from # Metclass type annotation clearly available
class MyMeta(type):
pass
# mypy metclass conflict error
class MyExampleDict(dict, metaclass=MyMeta):
def __init__(self, data: Dict):
super().__init__(data) However, if we make a metaclass that extends python's ABCMeta, mypy doesn't complain: from abc import ABCMeta
class MyMeta2(ABCMeta):
pass
# no mypy error with MyMeta2
class MyExampleDict2(dict, metaclass=MyMeta2):
def __init__(self, data: Dict):
super().__init__(data) Note that neither of the above results in a Python run-time error. |
Bug Report
Since mypy 0.990 I am getting a "Metaclass conflict" error for the definition of a class derived from a base class which uses a metaclass imported from a third-party library that doesn't provide type annotations.
To Reproduce
Also available as gist at: https://mypy-play.net/?mypy=latest&python=3.11&gist=6d41ba53b2226e3bef16df71554b10b1
Expected Behavior
No errors.
Actual Behavior
Your Environment
mypy.ini
(and other config files):More info
I tried some debugging and found out that:
mypy/checker.py
check_metaclass_compatibility()
method for the derived classes, the main difference betweenDerived
(which errors) andDerived2
(which doesn't) is thattyp.metaclass_type
isNone
in the first case (instead of the expectedMyMeta
) andMyMeta2
in the second (correctly).mypy/nodes.py
. When run for theDerived
object, the only candidate metaclass isMyMeta
(correctly), but then this is excluded in the followingfor
loop becauseMyMeta.type.mro
is[]
(I supposed because it's missing type annotation).The text was updated successfully, but these errors were encountered: