Skip to content

Conversation

@eumiro
Copy link
Contributor

@eumiro eumiro commented Aug 16, 2023

Simplify loops without condition X for X in Y to bare Y, or convert it to list() or set() or iter() if needed.

Copy link
Member

Choose a reason for hiding this comment

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

Nice catch

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert not list(files)
with pytest.raises(StopIteration):
next(files)

Alternative approach. Shouldn’t be too much difference in practice (especially in a test).

Copy link
Contributor Author

@eumiro eumiro Aug 18, 2023

Choose a reason for hiding this comment

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

This is really elegant. Anyway, since the previous block already expects a StopIteration, we do not have to repeat it here. I'll remove it altogether.

@potiuk potiuk merged commit 7700fb1 into apache:main Aug 20, 2023
@eumiro eumiro deleted the simplify-loops branch August 20, 2023 18:19
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Aug 27, 2023
@ephraimbuddy ephraimbuddy added this to the Airflow 2.7.1 milestone 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:dev-tools area:lineage area:logging area:production-image Production image improvements and fixes area:providers area:system-tests area:webserver Webserver related Issues provider:amazon AWS/Amazon - related issues provider:apache-hive provider:google Google (including GCP) related issues provider:microsoft-azure Azure-related issues provider:smtp 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.

6 participants