jpmorganchase / py-avro-schema

Generate Apache Avro schemas for Python types including standard library data-classes and Pydantic data models.
https://py-avro-schema.readthedocs.io/
Apache License 2.0
37 stars 6 forks source link

[QUESTION]: DecimalType assignment type linter error #57

Closed dada-engineer closed 1 year ago

dada-engineer commented 1 year ago

Hi there,

in vs code the following decimal type assignment (according to docs) creates a typing issue. Is this something that can be resolved in this project? 🤔

from decimal import Decimal
import py_avro_schema as pas

foo: pas.DecimalType[512, 255] = Decimal(10)

Pylance error:

Expression of type "Decimal" cannot be assigned to declared type "DecimalType"
  "Decimal" is incompatible with "DecimalType"

Python Version: 3.11.4 py-avor-schema Version: 3.2.0

faph commented 1 year ago

I think we noticed this too. I believe mypy does it correct but that does not help much.

We should be moving to Python’s new Annotated types. That’s what that is for after all.

dada-engineer commented 1 year ago

Would be great yes

faph commented 1 year ago

@dabdada I have started this ^^^ PR for this issue