Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pendulum_dt.Date can resolve to datetime.date #183

Closed
mikenerone opened this issue Jun 4, 2024 · 2 comments · Fixed by #184
Closed

pendulum_dt.Date can resolve to datetime.date #183

mikenerone opened this issue Jun 4, 2024 · 2 comments · Fixed by #184

Comments

@mikenerone
Copy link

mikenerone commented Jun 4, 2024

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
Copy link
Contributor

07pepa commented Jun 10, 2024

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

@07pepa
Copy link
Contributor

07pepa commented Jun 10, 2024

fixed here

@yezz123 yezz123 linked a pull request Jun 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants