You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ mypy test.py
test.py:3: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [misc]
I'm unsure if this is a mypy bug or not, but in my normal code, this results in this mypy error for each subclass of BaseXmlModel I have.
I also found this mypy issue which suggests that adding a # type: ignore[misc] to the class BaseXmlModel line could be a workaround: python/mypy#14033 (comment)
But to be honest, I do not know enough about Python metaclasses to give you a better problem analysis and solution proposal.
On the other hand, you may already have seen a similar issue, as you apparently added the same type ignore a few lines above the BaseXmlModel definition for version 2: https://github.com/dapper91/pydantic-xml/blob/v2.0.0b1/pydantic_xml/model.py#L202
The text was updated successfully, but these errors were encountered:
Yes, the problem is here.
mypy can't figure out that type(BaseModel) returns ModelMetaclass and thinks that BaseModel and BaseXmlModel have different metaclass roots which is prohibited in python.
The other problem is that ModelMetaclass located in an internal pydantic module which means it is not a public api and can be changed in the future.
Found the issue addressing that problem. They advice to import ModelMetaclass directly from pydantic._internal._model_construction.
Hi :) Again, thank you for your work and your quick fix in my previous issue!
I found a new problem in
v2.0.0b1
, which I could not reproduce inv1.0.0
. MWE:Running
mypy
on it results in:I'm unsure if this is a
mypy
bug or not, but in my normal code, this results in thismypy
error for each subclass ofBaseXmlModel
I have.I also found this
mypy
issue which suggests that adding a# type: ignore[misc]
to theclass BaseXmlModel
line could be a workaround: python/mypy#14033 (comment)But to be honest, I do not know enough about Python metaclasses to give you a better problem analysis and solution proposal.
On the other hand, you may already have seen a similar issue, as you apparently added the same type ignore a few lines above the
BaseXmlModel
definition for version 2: https://github.com/dapper91/pydantic-xml/blob/v2.0.0b1/pydantic_xml/model.py#L202The text was updated successfully, but these errors were encountered: