Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions airflow-ctl/src/airflowctl/ctl/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ def __init__(self, file_path: str | Path | None = None):
def _inspect_operations(self) -> None:
"""Parse file and return matching Operation Method with details."""

def _union_members(node: ast.expr) -> list[str]:
"""Get individual type names from a union type annotation."""
if isinstance(node, ast.BinOp) and isinstance(node.op, ast.BitOr):
return _union_members(node.left) + _union_members(node.right)
return [ast.unparse(node)]

def get_function_details(node: ast.FunctionDef, parent_node: ast.ClassDef) -> dict:
"""Extract function name, arguments, and return annotation."""
func_name = node.name
Expand All @@ -415,10 +421,7 @@ def get_function_details(node: ast.FunctionDef, parent_node: ast.ClassDef) -> di

if node.returns:
return_annotation = [
t.strip()
# TODO change this while removing Python 3.9 support
for t in ast.unparse(node.returns).split("|")
if t.strip() != ServerResponseError.__name__
t for t in _union_members(node.returns) if t != ServerResponseError.__name__
].pop()

return {
Expand Down
Loading