Skip to content

Commit 9816412

Browse files
refactor: Remove misleading return type from list_launch_templates() Typer command (#49)
The function returned a list value that was never consumed by callers since it's a Typer CLI command. Changed return type to None and removed unused Any import. Co-authored-by: Claude <noreply@anthropic.com>
1 parent c3074d4 commit 9816412

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

progress.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,27 @@ Both calls retrieved the same value for the same `instance_id`. The second call
452452
- Reused the existing `current_type` variable instead of creating `current_instance_type`
453453
- This eliminates one AWS API call when displaying current instance type
454454

455+
---
456+
457+
## 2026-01-18: Remove misleading return type from `list_launch_templates()` Typer command
458+
459+
**File:** `remote/ami.py`
460+
461+
**Issue:** The `list_launch_templates()` function had a misleading API contract:
462+
1. Return type annotation was `-> list[dict[str, Any]]`
463+
2. Line 117 returned an empty list `[]`
464+
3. Line 161 returned `templates` list
465+
4. However, as a Typer CLI command (decorated with `@app.command("list-templates")`), the return value is never consumed by callers
466+
467+
This is problematic because:
468+
- Typer command functions should return `None` or have no return type annotation
469+
- The returned value was never used by the CLI framework
470+
- The return type annotation created a misleading API contract implying the value could be used programmatically
471+
- The `Any` type import was only needed for this return type
472+
473+
**Changes:**
474+
- Changed return type from `-> list[dict[str, Any]]` to `-> None`
475+
- Changed `return []` on line 117 to `return` (early exit with no value)
476+
- Removed `return templates` statement on line 161 (implicit None return)
477+
- Removed the now-unused `from typing import Any` import
478+

remote/ami.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import random
22
import string
3-
from typing import Any
43

54
import typer
65
from rich.panel import Panel
@@ -97,7 +96,7 @@ def list_amis() -> None:
9796
def list_launch_templates(
9897
filter: str | None = typer.Option(None, "-f", "--filter", help="Filter by name"),
9998
details: bool = typer.Option(False, "-d", "--details", help="Show template details"),
100-
) -> list[dict[str, Any]]:
99+
) -> None:
101100
"""
102101
List all available EC2 launch templates.
103102
@@ -114,7 +113,7 @@ def list_launch_templates(
114113

115114
if not templates:
116115
typer.secho("No launch templates found", fg=typer.colors.YELLOW)
117-
return []
116+
return
118117

119118
if details:
120119
# Show detailed view with version info
@@ -158,8 +157,6 @@ def list_launch_templates(
158157

159158
console.print(table)
160159

161-
return templates
162-
163160

164161
@app.command()
165162
def launch(

0 commit comments

Comments
 (0)