dapper91 / pydantic-xml

python xml for humans
https://pydantic-xml.readthedocs.io
The Unlicense
155 stars 16 forks source link

[mypy] Incompatible types in assignment #65

Closed foarsitter closed 1 year ago

foarsitter commented 1 year ago

Thanks for providing this extension, it makes working with xml fun again.

The from_* methods are typed against BaseXmlModel which results in an mypy error.

message: Message | None = Message.from_xml(xml)
error: Incompatible types in assignment (expression has type "BaseXmlModel | None", variable has type "Message | None")

Pydantic itself uses a TypeVar bound to BaseModel so children are accepted as return type.

Is this something you want to support? If so, I can submit a PR.

dapper91 commented 1 year ago

@foarsitter Hi. Fixed it in version 0.7.0.

foarsitter commented 1 year ago

Great work @dapper91, thanks!