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

Improve ATTRIBUTE_REMOVED sentinel to use class and more context #40920

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Jul 21, 2024

ATTRIBUTE_REMOVED was a singleton object but then it made it difficult to find out which attribute has been removed. This PR changes the approach to allow for multiple AttributeRemoved objects as sentinel and compare class ratehr than object. The object contains name of the removed attribute. Better diagnostics at the expense of a bit more memory used.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

ATTRIBUTE_REMOVED was a singleton object but then it made it
difficult to find out which attribute has been removed. This PR
changes the approach to allow for multiple AttributeRemoved objects
as sentinel and compare class ratehr than object. The object contains
name of the removed attribute. Better diagnostics at the expense of
a bit more memory used.
@potiuk
Copy link
Member Author

potiuk commented Jul 21, 2024

>>> from airflow.utils.types import AttributeRemoved
>>> a = AttributeRemoved("aaaa")
>>> a.bbb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jarek/IdeaProjects/airflow/airflow/utils/types.py", line 60, in __getattr__
    raise RuntimeError(
RuntimeError: Attribute aaaa was removed on serialization and must be set again - found when accessing bbb.
>>> a.__class__ is AttributeRemoved
True
>>>

@potiuk
Copy link
Member Author

potiuk commented Jul 21, 2024

cc: @dstandish

@potiuk potiuk merged commit efca50a into apache:main Jul 23, 2024
48 checks passed
@potiuk potiuk deleted the improve-context-of-attribute-removed branch July 23, 2024 14:48
@ephraimbuddy ephraimbuddy added the type:improvement Changelog: Improvements label Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants