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

Import utc from datetime and normalize its import #33450

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

eumiro
Copy link
Contributor

@eumiro eumiro commented Aug 16, 2023

Replace pytz.UTC with stdlib's datetime.timezone.utc and normalize importing of datetime in touched files because bare timezone could come from other libs too.

There's one pytz-depending file left: tests/models/test_trigger.py, that could be replaced by stdlib's zoneinfo from Python 3.9 (i.e. when Python 3.8 support is dropped) or we could replace it by the backported pypi version right now.

@boring-cyborg boring-cyborg bot added area:providers provider:amazon-aws AWS/Amazon - related issues provider:cncf-kubernetes Kubernetes provider related issues provider:google Google (including GCP) related issues labels Aug 16, 2023
@hussein-awala hussein-awala merged commit bfe08a7 into apache:main Aug 16, 2023
47 checks passed
@eumiro eumiro deleted the less-pytz branch August 16, 2023 18:07
ferruzzi pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Aug 17, 2023
@uranusjr
Copy link
Member

I think pytz is implicitly required by some dependencies anyway, so there’s no point moving to the backported zoneinfo now. We can maybe do

try:
    from zoneinfo import ZoneInfo
except ImportError:
    from pytz import Timezone as ZoneInfo

to pre-emptively be ready for the transition when the transitive pytz dependency is dropped.

@eumiro
Copy link
Contributor Author

eumiro commented Aug 17, 2023

@uranusjr or we can just leave it this way and once Python 3.8 support is dropped, we switch that file directly to zoneinfo.

@uranusjr
Copy link
Member

Or maybe we can use Pendulum’s timezone support? It’s much too integrated into Airflow at this point I don’t see us dropping it at all.

@ephraimbuddy ephraimbuddy added this to the Airflow 2.7.1 milestone Aug 27, 2023
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Aug 27, 2023
ephraimbuddy pushed a commit that referenced this pull request Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:amazon-aws AWS/Amazon - related issues provider:cncf-kubernetes Kubernetes provider related issues provider:google Google (including GCP) related issues type:misc/internal Changelog: Misc changes that should appear in change log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants