Skip to content

Fix airflowctl boolean flags on Python 3.14#63587

Merged
potiuk merged 1 commit intoapache:mainfrom
Dev-iL:2603/ctl_boolean
Mar 14, 2026
Merged

Fix airflowctl boolean flags on Python 3.14#63587
potiuk merged 1 commit intoapache:mainfrom
Dev-iL:2603/ctl_boolean

Conversation

@Dev-iL
Copy link
Collaborator

@Dev-iL Dev-iL commented Mar 14, 2026

Summary

airflowctl was generating CLI options for boolean fields with both:

  • action=argparse.BooleanOptionalAction
  • type=bool

On Python 3.14, argparse.BooleanOptionalAction no longer accepts the type keyword, which caused parser construction to fail with:

TypeError: BooleanOptionalAction.__init__() got an unexpected keyword argument 'type'

This change updates Arg.add_to_parser() to drop type when the argument uses BooleanOptionalAction, 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 Arg objects.

This is backward compatible with older Python versions because BooleanOptionalAction is a flag action and does not consume a value that would need type conversion.

Tests

  • Added a regression test that exercises Arg.add_to_parser() with BooleanOptionalAction
  • Verified with:
pytest airflow-ctl/tests/airflow_ctl/ctl/test_cli_config.py -xvs

References


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Codex gpt-5.4 following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {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.

@bugraoz93
Copy link
Contributor

Thanks @Dev-iL ! Do you think this would be enough to support 3.14?
We are already limiting Python version here. Limiting makes already not usable with Python 3.14.

requires-python = ">=3.10,!=3.14"

Copy link
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

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

Looks good, left a comment :)

@Dev-iL
Copy link
Collaborator Author

Dev-iL commented Mar 14, 2026

Thanks @Dev-iL ! Do you think this would be enough to support 3.14? We are already limiting Python version here. Limiting makes already not usable with Python 3.14.

requires-python = ">=3.10,!=3.14"

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.

@potiuk potiuk merged commit 27a7164 into apache:main Mar 14, 2026
85 checks passed
@bugraoz93
Copy link
Contributor

Thanks @Dev-iL ! Do you think this would be enough to support 3.14? We are already limiting Python version here. Limiting makes already not usable with Python 3.14.

requires-python = ">=3.10,!=3.14"

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.

@Dev-iL Dev-iL deleted the 2603/ctl_boolean branch March 15, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants