marcosschroh / dataclasses-avroschema

Generate avro schemas from python dataclasses, Pydantic models and Faust Records. Code generation from avro schemas. Serialize/Deserialize python instances with avro schemas.
https://marcosschroh.github.io/dataclasses-avroschema/
MIT License
218 stars 67 forks source link

mypy errors on example model when upgrading to version 0.38 #281

Closed mdipietrowf closed 1 year ago

mdipietrowf commented 1 year ago

Describe the bug When running mypy on avro models after updating to 0.38.0, the following errors are displayed:

example.py:9: error: Definition of "validate" in base class "Model" is incompatible with definition in base class "AvroModel"  [misc]

example.py:9: error: Definition of "validate" in base class "ModelT" is incompatible with definition in base class "AvroModel"  [misc]

example.py:15: error: Incompatible types in assignment (expression has type "Tuple[str, str, str]", variable has type "Tuple[str]")  [assignment]

example.py:17: error: Incompatible types in assignment (expression has type "None", variable has type "str")  [assignment]

To Reproduce Run mypy v1.1.1 on a file containing the UserAdvance class as in the example https://marcosschroh.github.io/dataclasses-avroschema/faust_records/

using faust-streaming 0.10.8

Expected behavior No mypy errors from creating example model.

marcosschroh commented 1 year ago

Hi @mdipietrowf

Thanks for noticing this issue. I think we should create a new class that inherits from record.Model, AvroModel and redefine the validate that will use the super().validate() in order to solve the problem and the end users will need to only inherits from one class (similar to what we do with BaseModel + AvroModel = AvroBaseModel for pydantic integration.

marcosschroh commented 1 year ago

The faust integration has been updated so now you should not have any mypy errors