Skip to content

fix: add CLI passenger option and click dependency - #210

Open
hishamank wants to merge 1 commit into
punitarani:mainfrom
hishamank:fix-cli-passengers-click
Open

fix: add CLI passenger option and click dependency#210
hishamank wants to merge 1 commit into
punitarani:mainfrom
hishamank:fix-cli-passengers-click

Conversation

@hishamank

@hishamank hishamank commented Jun 30, 2026

Copy link
Copy Markdown

Summary

  • add missing click runtime dependency used by fli.cli.utils
  • add --passengers/-p to flights, dates, and multi CLI commands
  • pass the requested adult count into PassengerInfo instead of hardcoding adults=1
  • echo passenger count in JSON query output for flight/date searches
  • add CLI tests covering passenger handling

Verification

  • uv run ruff check fli/cli/commands/flights.py fli/cli/commands/dates.py fli/cli/commands/multi.py tests/cli/test_flights.py tests/cli/test_dates.py tests/cli/test_multi.py
  • uv run pytest tests/cli/test_flights.py tests/cli/test_dates.py tests/cli/test_multi.py -q → 50 passed
  • uv run pytest tests/cli tests/models/test_flight_search_filters.py tests/models/test_date_search_filters.py -q → 149 passed

Note: I also started the full uv run pytest -q suite, but it produced no output after ~3 minutes and appeared to be blocked on broader/live tests, so I stopped it and ran the relevant non-live suites above.

Greptile Summary

This PR fixes a missing click runtime dependency and adds a --passengers/-p option to the flights, dates, and multi CLI commands, replacing a hardcoded adults=1 in PassengerInfo with the user-supplied value.

  • Dependency fix: click>=8.0.0 is added to pyproject.toml because fli/cli/utils.py directly imports Context and Parameter from it; previously the import worked only because typer pulls click in transitively.
  • Passenger option: All three commands gain --passengers/-p (default 1, min 1); the value flows into PassengerInfo(adults=passengers) and is echoed in the JSON query block for flights and dates.
  • Tests: New tests in test_flights.py, test_dates.py, and test_multi.py verify both the filter value and (for JSON-capable commands) the query echo.

Confidence Score: 4/5

The change is straightforward and well-tested; the only rough edge is that the dates command error-path query dicts omit the new field.

The core logic — wiring the CLI flag through to PassengerInfo — is correct across all three commands and is covered by new unit tests. The one gap is that the two inline error-path query dicts in dates.py do not include passengers, so a JSON consumer checking query.passengers on a parse or validation failure would find the key absent, inconsistent with the success response.

fli/cli/commands/dates.py — the ParseError and AttributeError/ValueError handler inline query dicts should include passengers to match the success-path shape.

Important Files Changed

Filename Overview
fli/cli/commands/dates.py Adds --passengers/-p option and wires it into PassengerInfo and the JSON query echo on the success path; error-path inline query dicts omit the new field.
fli/cli/commands/flights.py Adds --passengers/-p option to the flights command; correctly threaded through _search_flights_core, PassengerInfo, and the JSON query dict.
fli/cli/commands/multi.py Adds --passengers/-p option to the multi command and passes it into PassengerInfo; no JSON output path, so no query-echo inconsistency.
pyproject.toml Adds click>=8.0.0 as an explicit runtime dependency, correctly reflecting the direct import in fli/cli/utils.py.
tests/cli/test_flights.py Adds two new tests: one asserting PassengerInfo.adults is set correctly, another verifying the JSON query echo includes the passenger count.
tests/cli/test_dates.py Adds test_dates_with_passengers verifying both the PassengerInfo filter and the JSON query echo include the requested passenger count.
tests/cli/test_multi.py Adds test_with_passengers to the TestMultiCityCommand class verifying PassengerInfo.adults is set from the --passengers flag.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant User
    participant CLI as CLI Command(flights/dates/multi)
    participant Core as PassengerInfo
    participant Search as SearchFlights/SearchDates

    User->>CLI: fli flights JFK LHR 2026-10-25 --passengers 2
    CLI->>CLI: "Validate passengers (min=1)"
    CLI->>Core: "PassengerInfo(adults=passengers)"
    CLI->>Search: "search(FlightSearchFilters(passenger_info=...))"
    Search-->>CLI: results
    CLI-->>User: "Flight results (text or JSON with query.passengers=2)"
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant User
    participant CLI as CLI Command(flights/dates/multi)
    participant Core as PassengerInfo
    participant Search as SearchFlights/SearchDates

    User->>CLI: fli flights JFK LHR 2026-10-25 --passengers 2
    CLI->>CLI: "Validate passengers (min=1)"
    CLI->>Core: "PassengerInfo(adults=passengers)"
    CLI->>Search: "search(FlightSearchFilters(passenger_info=...))"
    Search-->>CLI: results
    CLI-->>User: "Flight results (text or JSON with query.passengers=2)"
Loading

Comments Outside Diff (1)

  1. fli/cli/commands/dates.py, line 441-473 (link)

    P2 passengers missing from error-path query dicts

    The success path adds "passengers": passengers to the query dict, but the two inline fallback dicts built inside the ParseError handler (lines ~441–473) and the AttributeError/ValueError handler (lines ~493–528) omit it. Any consumer inspecting the JSON error payload for query.passengers would get None/KeyError on a parse failure, inconsistent with the success response shape.

    The simplest fix is to include "passengers": passengers in both inline error-path dicts, or (better) to always reference the already-constructed query variable from line 299 the way the flights command does in _search_flights_core.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: fli/cli/commands/dates.py
    Line: 441-473
    
    Comment:
    **`passengers` missing from error-path query dicts**
    
    The success path adds `"passengers": passengers` to the `query` dict, but the two inline fallback dicts built inside the `ParseError` handler (lines ~441–473) and the `AttributeError`/`ValueError` handler (lines ~493–528) omit it. Any consumer inspecting the JSON error payload for `query.passengers` would get `None`/`KeyError` on a parse failure, inconsistent with the success response shape.
    
    The simplest fix is to include `"passengers": passengers` in both inline error-path dicts, or (better) to always reference the already-constructed `query` variable from line 299 the way the `flights` command does in `_search_flights_core`.
    
    How can I resolve this? If you propose a fix, please make it concise.

    Fix in Cursor Fix in Claude Code Fix in Codex

Fix All in Cursor Fix All in Claude Code Fix All in Codex

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
fli/cli/commands/dates.py:441-473
**`passengers` missing from error-path query dicts**

The success path adds `"passengers": passengers` to the `query` dict, but the two inline fallback dicts built inside the `ParseError` handler (lines ~441–473) and the `AttributeError`/`ValueError` handler (lines ~493–528) omit it. Any consumer inspecting the JSON error payload for `query.passengers` would get `None`/`KeyError` on a parse failure, inconsistent with the success response shape.

The simplest fix is to include `"passengers": passengers` in both inline error-path dicts, or (better) to always reference the already-constructed `query` variable from line 299 the way the `flights` command does in `_search_flights_core`.

Reviews (1): Last reviewed commit: "fix: add CLI passenger option and click ..." | Re-trigger Greptile

felciano added a commit to felciano/fli that referenced this pull request Aug 31, 2026
The success path echoes "passengers" in the JSON query block, but the two
inline query dicts in the ParseError and AttributeError/ValueError handlers
omitted it, so a consumer reading query.passengers hit a KeyError on parse
failures. Flagged in review on upstream PR punitarani#210 but left unfixed there.
felciano added a commit to felciano/fli that referenced this pull request Aug 31, 2026
…alls

fli/cli imports rich (console.py, utils.py, commands/airports.py) and
fli/mcp/server.py imports mcp.types.Icon, but neither package was declared
in pyproject.toml. Both arrived only transitively -- rich via typer, mcp via
fastmcp. This is the same bug class that broke click: typer dropped its click
dependency after 0.16, and every fresh pipx install died with
ModuleNotFoundError. typer 0.27.2 no longer declares click at all, leaving
rich as the last load-bearing transitive edge.

Declare "rich>=13.8.0" in [project].dependencies and "mcp>=1.15.0" in the
mcp extra, then regenerate uv.lock with the resolver (5 added lines, no
version churn). The rich floor (13.8.0) is deliberately higher than typer 0.16's
declared rich>=10.11.0, pinning the version fli/cli actually relies on rather
than whatever floor typer happens to carry. The mcp floor is the true API floor, verified by install: Icon is
absent from mcp.types in 1.14.0 and present in 1.15.0 -- upstream's proposed
>=1.2.0 would have declared a floor the code cannot run on.

Adds tests/test_dependency_declarations.py, which AST-walks every module
under fli/ and diffs the third-party imports against the declared
requirements, so the bug class fails CI rather than a user's install.

Takes only the undeclared-dependency half of upstream PR punitarani#222. Its
fli/cli/utils.py hunk (click.Context/Parameter -> typer.Context/
typer.CallbackParam) is deliberately not applied, as it would revert the
verified click handling from PR punitarani#210.

Co-authored-by: Carter Temm <cartertemm@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant