1fanwang opened a new pull request, #66768:
URL: https://github.com/apache/airflow/pull/66768

   Following the dev-list lazy consensus on airflowctl parameter style[1], 
auto-generated commands such as `airflowctl dags get-details` now accept 
required primitive parameters positionally:
   
   ```
   airflowctl dags get-details my_dag_id
   ```
   
   instead of the previous `--dag-id my_dag_id` form. Optional parameters and 
booleans keep the `--flag` form.
   
   This matches the established precedent set by 0.1.1's pause/unpause 
positionalization (#59936) and aligns airflowctl with the conventions of the 
existing `airflow` CLI for required params.
   
   A parameter is "required" when the operation method declares it without a 
default and without `| None` in its annotation. Datamodel-expanded body fields 
(e.g. fields of `BackfillPostBody`) are unaffected and keep `--flag`.
   
   ## What changed
   
   - `airflow-ctl/src/airflowctl/ctl/cli_config.py` — `_inspect_operations` now 
captures required-ness from the AST (offset `len(args) - len(defaults)` for the 
standard Python convention). `_create_args_map_from_operation` branches on 
positional vs flag; a new `_create_positional_arg` helper drops 
`default=`/`dest=` (argparse rejects those on positional args).
   - `airflow-ctl/tests/airflow_ctl/ctl/test_cli_config.py` — two new tests 
cover the required-positional path and the optional-with-default path. Existing 
22 tests still pass with `test_command_factory` updated to reflect the new 
positional shape for `get` and `delete`.
   - `airflow-ctl/RELEASE_NOTES.rst` — entry under Unreleased.
   
   ## How was this tested?
   
   ```
   airflowctl dags get-details my_dag           # positional, exit 0
   airflowctl dags get-details                  # missing required arg
     error: the following arguments are required: dag_id  (exit 2)
   ```
   
   22/22 existing + 2 new tests pass.
   
   [1] https://lists.apache.org/thread/m1qvcvow3l17ytv40vhslh40wn3rntrm


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to