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

Enhance magic methods on XComArg for UX #21882

Merged
merged 2 commits into from
Mar 3, 2022

Conversation

uranusjr
Copy link
Member

@uranusjr uranusjr commented Mar 1, 2022

See #21853. We can do better.

@uranusjr uranusjr requested review from kaxil, XD-DENG and ashb as code owners March 1, 2022 00:54
uranusjr added 2 commits March 1, 2022 23:28
Implementing Python's magic methods for purposes not matching their
original design can have unwanted consequences due to default
interactions between those methods. This implements a custom __iter__ so
the custom __getitem__ does not trigger the default __iter__ behavior
and result in bad run-time behavior.
@malthe
Copy link
Contributor

malthe commented Mar 2, 2022

>>> class A:
...     def __getitem__(self, name): print name; return repr(name)
... 
>>> a = A()
>>> next(iter(a))
0
'0'

OK that is surprising. Unexpected Python magic!

@malthe malthe self-requested a review March 2, 2022 12:27
@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Mar 2, 2022
@github-actions
Copy link

github-actions bot commented Mar 2, 2022

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@uranusjr uranusjr force-pushed the xcom-arg-index-lookup-fail branch from 8550636 to 6937ca5 Compare March 2, 2022 12:46
Copy link
Member

@ashb ashb left a comment

Choose a reason for hiding this comment

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

Should we add tests?

@potiuk
Copy link
Member

potiuk commented Mar 2, 2022

Should we add tests?

Actually two short tests generating the exceptions would be nice :)

@uranusjr
Copy link
Member Author

uranusjr commented Mar 3, 2022

Tests added

@potiuk
Copy link
Member

potiuk commented Mar 3, 2022

random ci failure. Merging

@potiuk potiuk merged commit 1956f38 into apache:main Mar 3, 2022
@uranusjr uranusjr deleted the xcom-arg-index-lookup-fail branch March 3, 2022 09:11
@ephraimbuddy ephraimbuddy added the type:improvement Changelog: Improvements label Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full tests needed We need to run full set of tests for this PR to merge type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants