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

Replace strftime with f-strings where nicer #33455

Merged
merged 1 commit into from
Aug 23, 2023
Merged

Conversation

eumiro
Copy link
Contributor

@eumiro eumiro commented Aug 16, 2023

No description provided.

@uranusjr
Copy link
Member

I’m not particular sure about this, strftime is more obvious and (subjectively) easier to read. The f-string format can be beneficial if the formatted date string is going into another f-string (as in some cases here) but not when it’s on its own.

@eumiro
Copy link
Contributor Author

eumiro commented Aug 17, 2023

@uranusjr Reduced to being part of larger f-strings.

@potiuk
Copy link
Member

potiuk commented Aug 20, 2023

I’m not particular sure about this, strftime is more obvious and (subjectively) easier to read. The f-string format can be beneficial if the formatted date string is going into another f-string (as in some cases here) but not when it’s on its own.

@uranusjr Reduced to being part of larger f-strings.

I really like conciseness of the way it's done now. It very nicely focuses the concerns (date + format) in one place within the larger f-string. @uranusjr -> is that good for you as well?

Comment on lines 40 to 41
"start_time": datetime(2012, 1, 2, 0, 0).strftime("%s") + "000",
"end_time": datetime(2012, 1, 3, 0, 0).strftime("%s") + "000",
"start_time": f"{datetime(2012, 1, 2, 0, 0):%s}000",
"end_time": f"{datetime(2012, 1, 3, 0, 0):%s}000",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s probably better to just convert these to literals with a comment, going through datetime just to convert into a datetime is a bit over the top.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to a more explicit version.

@potiuk potiuk merged commit 94f70d8 into apache:main Aug 23, 2023
64 checks passed
@eumiro eumiro deleted the no-strftime branch August 23, 2023 20:13
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Oct 2, 2023
@ephraimbuddy ephraimbuddy added this to the Airflow 2.7.2 milestone Oct 2, 2023
ephraimbuddy pushed a commit that referenced this pull request Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dev-tools area:logging area:providers area:Scheduler including HA (high availability) scheduler provider:amazon-aws AWS/Amazon - related issues provider:apache-kylin provider:elasticsearch provider:google Google (including GCP) related issues provider:http provider:oracle 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.

4 participants