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

Allow Param to support a default value of None #19034

Merged
merged 3 commits into from
Oct 19, 2021

Conversation

jedcunningham
Copy link
Member

@jedcunningham jedcunningham commented Oct 17, 2021

Allow Param to support a default value of None.

This also stores the default value in value instead of default, since we later will update the resolved value.

closes: #18909

@@ -24,6 +24,16 @@
from airflow.exceptions import AirflowException


class NoValueSentinel:
Copy link
Member Author

Choose a reason for hiding this comment

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

I was running into differing id's with a naive object() sentinel, so I went with this class and used isinstance for comparison. Side benefit, allows for a better str/repr.

Copy link
Member

@uranusjr uranusjr Oct 18, 2021

Choose a reason for hiding this comment

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

I think we now have like five different sentinel class implementations in the code base. I have one for DAG(schedule_interval). Probably should unify them somewhat into airflow.utils.types at some point.

Further reading for those interested: PEP 661: Sentinel Values

Copy link
Member

@kaxil kaxil left a comment

Choose a reason for hiding this comment

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

On higher level it makes sense but would defer to @msumit

@msumit
Copy link
Contributor

msumit commented Oct 18, 2021

On higher level it makes sense but would defer to @msumit

lgtm

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Oct 18, 2021
@github-actions
Copy link

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.

@jedcunningham jedcunningham changed the title Fix None default Param; refactor Param default handling Allow Param to support a default value of None Oct 18, 2021
@jedcunningham jedcunningham marked this pull request as ready for review October 18, 2021 19:53
@jedcunningham jedcunningham added this to the Airflow 2.2.1 milestone Oct 18, 2021
@uranusjr uranusjr merged commit ee4fb07 into apache:main Oct 19, 2021
@uranusjr uranusjr deleted the none_params branch October 19, 2021 20:30
jedcunningham added a commit that referenced this pull request Oct 20, 2021
jedcunningham added a commit to astronomer/airflow that referenced this pull request Oct 26, 2021
sharon2719 pushed a commit to sharon2719/airflow that referenced this pull request Oct 27, 2021
jedcunningham added a commit to astronomer/airflow that referenced this pull request Oct 27, 2021
@jedcunningham jedcunningham added the type:bug-fix Changelog: Bug Fixes label Apr 7, 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:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None values no longer accepted in params
4 participants