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

PositiveFloat is not supported #23

Closed Lazloo closed 2 years ago

Lazloo commented 2 years ago

I use the PositiveFloat Fields in my pydantic model

from pydantic import PositiveFloat
class ModelExample(BaseModel):
    price: PositiveFloat

However, this seems not yet supported by py-avro-schema:

TypeError: Cannot generate Avro schema for Python type <class 'pydantic.types.PositiveFloat'>
faph commented 2 years ago

I guess with respect to Avro schemas this should map to a double type? https://py-avro-schema.readthedocs.io/en/stable/types.html#float

faph commented 2 years ago

@Lazloo Could you please confirm that this test reproduces the issue and defines the expected behavior?

Lazloo commented 2 years ago

Assume you mean https://github.com/jpmorganchase/py-avro-schema/pull/24/commits/6f0745d10f8115e2caaeb7488b255a1876c475b4

Yes! This describes the issue

faph commented 2 years ago

@Lazloo This PR should allow you to use types like pydantic.PositiveFloat: PR #24. We will release this on Monday.

faph commented 2 years ago

@Lazloo version 1.1.0 now released at https://pypi.org/project/py-avro-schema/