pendulum_dt.Date can resolve to datetime.date
mikenerone opened this issue · comments
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.
that is correct asumption... i am adding fix and checks