Fix airflowctl boolean flags on Python 3.14#63587
Conversation
|
Thanks @Dev-iL ! Do you think this would be enough to support 3.14? airflow/airflow-ctl/pyproject.toml Line 29 in 75d0a9d |
bugraoz93
left a comment
There was a problem hiding this comment.
Looks good, left a comment :)
This change was split from the main 3.14 PR where the above suggesttion is already included. There weren't other airflowctl failures - will see what happens on CI after rebase. It is possble that this is all it takes. |
Thanks! Will later check and see if we can safely remove the limitation further. |
Summary
airflowctlwas generating CLI options for boolean fields with both:action=argparse.BooleanOptionalActiontype=boolOn Python 3.14,
argparse.BooleanOptionalActionno longer accepts thetypekeyword, which caused parser construction to fail with:This change updates
Arg.add_to_parser()to droptypewhen the argument usesBooleanOptionalAction, while leaving the existing generated argument metadata unchanged.Why this approach
The fix is applied at the final parser handoff point rather than changing every code path that creates boolean arguments. That keeps the behavior centralized and preserves the existing test expectations around generated
Argobjects.This is backward compatible with older Python versions because
BooleanOptionalActionis a flag action and does not consume a value that would need type conversion.Tests
Arg.add_to_parser()withBooleanOptionalActionReferences
argparse.py:https://raw.githubusercontent.com/python/cpython/3.14/Lib/argparse.py
argparse.py:https://raw.githubusercontent.com/python/cpython/3.12/Lib/argparse.py
airflow-ctl/src/airflowctl/ctl/cli_config.pyairflow-ctl/tests/airflow_ctl/ctl/test_cli_config.pyWas generative AI tooling used to co-author this PR?
Generated-by: Codex gpt-5.4 following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.