Google Flights MCP, CLI and Python Library
fix(cli): strip underscore prefix from numeric airline codes in output
Punit Aranif2c639c7d87a
diff --git a/fli/cli/commands/dates.py b/fli/cli/commands/dates.pyindex baf5321..3e1b5e6 100644--- a/fli/cli/commands/dates.py+++ b/fli/cli/commands/dates.py@@ -231,7 +231,11 @@ def dates("departure_window": (f"{departure_window[0]}-{departure_window[1]}" if departure_window else None),- "airlines": [airline.name for airline in parsed_airlines] if parsed_airlines else None,+ "airlines": (+ [airline.name.lstrip("_") for airline in parsed_airlines]+ if parsed_airlines+ else None+ ),"sort_by_price": sort_by_price,"days": [day.value for day in selected_days],}diff --git a/fli/cli/utils.py b/fli/cli/utils.pyindex 201175f..9658989 100644--- a/fli/cli/utils.py+++ b/fli/cli/utils.py@@ -171,7 +171,7 @@ def serialize_airport(airport: Airport) -> dict[str, str]:def serialize_airline(airline: Airline) -> dict[str, str]:"""Serialize an airline for machine-readable output."""- return {"code": airline.name, "name": airline.value}+ return {"code": airline.name.lstrip("_"), "name": airline.value}def serialize_flight_leg(leg: Any) -> dict[str, Any]:@@ -329,7 +329,7 @@ def display_flight_results(flights: list):segments.add_column("Arrive", style="green", no_wrap=True)for leg in flight.legs:- airline_flight = f"{leg.airline.name} {leg.flight_number}"+ airline_flight = f"{leg.airline.name.lstrip('_')} {leg.flight_number}"segments.add_row(airline_flight,format_airport(leg.departure_airport),diff --git a/tests/cli/test_utils.py b/tests/cli/test_utils.pyindex 1789545..1f2685e 100644--- a/tests/cli/test_utils.py+++ b/tests/cli/test_utils.py@@ -297,6 +297,22 @@ def test_display_date_results_uses_returned_currency():assert "€118.00" in output+def test_serialize_airline_strips_numeric_prefix():+ """Numeric-prefix airline codes should not include the underscore in output."""+ from fli.cli.utils import serialize_airline++ result = serialize_airline(Airline._3F)+ assert result == {"code": "3F", "name": "FlyOne Armenia"}+++def test_serialize_airline_normal_code():+ """Normal airline codes should serialize unchanged."""+ from fli.cli.utils import serialize_airline++ result = serialize_airline(Airline.BA)+ assert result == {"code": "BA", "name": "British Airways"}++def test_serialize_flight_result_one_way():"""JSON flight serialization should use machine-readable nested fields."""flight = _make_flight_result(price=159.0)@@ -309,6 +325,16 @@ def test_serialize_flight_result_one_way():assert payload["legs"][0]["airline"]["code"] == "DL"+def test_serialize_flight_result_numeric_prefix_airline():+ """Numeric-prefix airline codes in flight legs should not have underscore."""+ flight = _make_flight_result(price=200.0, airline=Airline._3F, flight_number="3F101")++ payload = serialize_flight_result(flight)++ assert payload["legs"][0]["airline"]["code"] == "3F"+ assert payload["legs"][0]["airline"]["name"] == "FlyOne Armenia"++def test_serialize_flight_result_round_trip():"""Round-trip JSON serialization should expose outbound and return segments."""outbound = _make_flight_result(price=317.0, flight_number="DL100")