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 DateTime wrapper losing tz and timezone values in 2.8.1 #188

Closed
chrisguidry opened this issue Jun 13, 2024 · 1 comment · Fixed by #189
Closed

Pendulum DateTime wrapper losing tz and timezone values in 2.8.1 #188

chrisguidry opened this issue Jun 13, 2024 · 1 comment · Fixed by #189

Comments

@chrisguidry
Copy link
Contributor

After upgrading to pydantic-extra-types==2.8.1, we're seeing some bizarre artifacts with timezones for the Pendulum wrapper types.

Repro:

from datetime import timedelta

from pydantic import BaseModel
from pydantic_extra_types.pendulum_dt import DateTime


class MyModel(BaseModel):
    dt: DateTime


m = MyModel(dt="2021-02-03T04:05:06.777777Z")

# The timezone appears to be set...
print(m.dt)
# ..., but when doing date math, it is dropped
print(m.dt - timedelta(seconds=10))

# Only the tzinfo is set, the others are None
print("tzinfo:", m.dt.tzinfo)
print("tz:", m.dt.tz)
print("timezone:", m.dt.timezone)

2.8.0:

$ pip install pydantic-extra-types==2.8.0 && python repro.py 
...
2021-02-03 04:05:06.777777+00:00
2021-02-03 04:04:56.777777+00:00
tzinfo: UTC
tz: UTC
timezone: UTC

2.8.1:

$ pip install pydantic-extra-types==2.8.1 && python repro.py 
...
2021-02-03 04:05:06.777777+00:00
2021-02-03 04:04:56.777777        <-- here the timezone is gone
tzinfo: UTC
tz: None
timezone: None
@chrisguidry
Copy link
Contributor Author

It seems like this may have been introduced in #184 or #185, I'm trying to narrow that down locally

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.

1 participant