pydantic / pydantic-extra-types

Extra Pydantic types.
MIT License
176 stars 47 forks source link

pendulum_dt.Date can resolve to datetime.date #183

Closed mikenerone closed 2 months ago

mikenerone commented 2 months ago

IIRC, the intent is the annotating a field with pendulum_dt.Date will guarantee that the field will contain a pendulum.Date object (or in this case at least a subclass of it), so callers can be confident that pendulum's methods will be available on it. Currently (as of the recent release of v2.8.0, but also prior to that), that is not the behavior:

In [1]: from pydantic_extra_types.pendulum_dt import Date; from pydantic import TypeAdapter; adapter = TypeAdapter(Date)

In [2]: adapter.validate_python("1990-07-02T00:00:00.000+0000")
Out[2]: datetime.date(1990, 7, 2)

In [3]: adapter.validate_python("1990-07-02")
Out[3]: datetime.date(1990, 7, 2)

As you can see above, a standard datetime.date object is returned.

07pepa commented 2 months ago

that is correct asumption... i am adding fix and checks

07pepa commented 2 months ago

fixed here