This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 27a716431f9 Fix airflowctl boolean flags on Python 3.14 (#63587)
27a716431f9 is described below

commit 27a716431f9c2e127c8e9d24c8e20f6675b17cb8
Author: Dev-iL <[email protected]>
AuthorDate: Sat Mar 14 23:28:29 2026 +0200

    Fix airflowctl boolean flags on Python 3.14 (#63587)
---
 airflow-ctl/src/airflowctl/ctl/cli_config.py         |  5 ++++-
 airflow-ctl/tests/airflow_ctl/ctl/test_cli_config.py | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/airflow-ctl/src/airflowctl/ctl/cli_config.py 
b/airflow-ctl/src/airflowctl/ctl/cli_config.py
index bdcd8b2fb90..5f17c603357 100755
--- a/airflow-ctl/src/airflowctl/ctl/cli_config.py
+++ b/airflow-ctl/src/airflowctl/ctl/cli_config.py
@@ -152,7 +152,10 @@ class Arg:
                     return self._is_valid_directory(parser, x)
 
                 self.kwargs["type"] = type
-        parser.add_argument(*self.flags, **self.kwargs)
+        kwargs = self.kwargs.copy()
+        if kwargs.get("action") is argparse.BooleanOptionalAction:
+            kwargs.pop("type", None)
+        parser.add_argument(*self.flags, **kwargs)
 
     def _is_valid_directory(self, parser, arg):
         if not os.path.isdir(arg):
diff --git a/airflow-ctl/tests/airflow_ctl/ctl/test_cli_config.py 
b/airflow-ctl/tests/airflow_ctl/ctl/test_cli_config.py
index 6d5bf39e7ab..117f874c346 100644
--- a/airflow-ctl/tests/airflow_ctl/ctl/test_cli_config.py
+++ b/airflow-ctl/tests/airflow_ctl/ctl/test_cli_config.py
@@ -17,6 +17,7 @@
 
 from __future__ import annotations
 
+import argparse
 from argparse import BooleanOptionalAction
 from textwrap import dedent
 
@@ -288,6 +289,22 @@ class TestCommandFactory:
 
 
 class TestCliConfigMethods:
+    def test_add_to_parser_drops_type_for_boolean_optional_action(self):
+        """Test add_to_parser removes type for BooleanOptionalAction."""
+        parser = argparse.ArgumentParser()
+        arg = Arg(
+            flags=("--run-backwards",),
+            action=BooleanOptionalAction,
+            default=False,
+            help="run_backwards for backfill operation",
+            type=bool,
+        )
+
+        arg.add_to_parser(parser)
+
+        assert parser.parse_args(["--run-backwards"]).run_backwards is True
+        assert parser.parse_args(["--no-run-backwards"]).run_backwards is False
+
     def test_merge_commands(self, no_op_method):
         """Test the merge_commands method."""
         # Create two Command objects with different names and help texts

Reply via email to