feat: expose aircraft, legroom, amenities, codeshares, and emissions in flight results#95
Open
iclems wants to merge 2 commits intopunitarani:mainfrom
Open
feat: expose aircraft, legroom, amenities, codeshares, and emissions in flight results#95iclems wants to merge 2 commits intopunitarani:mainfrom
iclems wants to merge 2 commits intopunitarani:mainfrom
Conversation
…in flight results Parse additional per-leg details from the Google Flights API response (aircraft type, seat legroom, codeshare partners, Wi-Fi/power/IFE availability) and itinerary-level CO2 emissions data. All new fields are optional and only included in the MCP output when present, so existing consumers are unaffected. Made-with: Cursor
- Set power/in_seat_entertainment to explicit False when amenities data is present but feature is absent (mirrors wifi behavior) - Break long wifi assignment line to stay within 100-char limit - Include both outbound_emissions and return_emissions for round trips instead of silently dropping the return leg's CO2 data Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
aircraft(e.g. "Boeing 777"),legroom(e.g. "31 in"),codeshares(e.g.[{"airline": "DL", "flight_number": "8747"}]), and onboard amenities (wifi,power,in_seat_entertainment) from the raw Google Flights API response.co2_grams,typical_co2_grams,diff_percent) when available.Noneby default) and only included in the MCP JSON output when present, so existing consumers see no change.Files changed
fli/models/google_flights/base.pyEmissionsmodel; added optional fields toFlightLegandFlightResultfli/models/google_flights/__init__.pyEmissionsfli/search/flights.py_parse_leg_details()and_parse_emissions()static methods to extract new data from raw API arraysfli/mcp/server.py_serialize_emissions()helper; updated leg and result serializers to conditionally include new fieldsMapping from raw Google Flights data
fl[17]"Boeing 777"fl[14]"31 in"fl[15][["DL","8747",null,"Delta"]]fl[12][1]truefl[12][11]3(AC+USB)fl[12][9]truedata[0][18][7/8/3]329000 / 369000 / -11Test plan
test_complex_round_trip_search— unrelated network issue)Made with Cursor
Greptile Summary
This PR enriches flight search results with per-leg details (aircraft type, legroom, codeshares, Wi-Fi/power/entertainment amenities) and itinerary-level CO₂ emissions data, all surfaced as optional fields so existing consumers are unaffected.
EmissionsPydantic model and optional fields onFlightLeg/FlightResultare clean and backward-compatible._parse_leg_details()defensively handles missing/malformed API array entries.powerandin_seat_entertainmentare typedbool | Nonein the model but only ever assignedTrueby the parser —Falseis never produced, making it impossible to distinguish "API reported no power" from "API didn't return the field."return_flight.emissionsis silently discarded; only the outbound leg's CO₂ data appears in the serialised output._parse_leg_details(~110 chars) exceeds the project's configured 100-character limit and will failmake lint.Confidence Score: 5/5
power/in_seat_entertainmentboolean asymmetry and the round-trip emissions omission are design inconsistencies worth addressing but neither breaks existing behaviour, corrupts data, nor fails existing tests. The line-length violation is a style issue. All new fields are optional and the change is fully backward-compatible.Important Files Changed
_parse_leg_details()and_parse_emissions()static methods;power/in_seat_entertainmentare never set toFalse(type mismatch vs model), and a line exceeds the 100-char style limit._serialize_emissions()and conditionally includes new fields in leg/result serializers; round-trip return-leg emissions are silently discarded.FlightLegand newEmissionsmodel; clean, backward-compatible Pydantic changes.Emissionsmodel; trivial, correct change.Sequence Diagram
sequenceDiagram participant C as Caller (MCP / CLI) participant S as SearchFlights participant A as Google Flights API C->>S: search(filters) S->>A: POST GetShoppingResults A-->>S: raw JSON (data[]) loop for each flight in data[2/3] S->>S: _parse_flights_data(data) S->>S: _parse_leg_details(fl) → aircraft, legroom, codeshares, wifi, power, ent. S->>S: _parse_emissions(data) → Emissions(co2_grams, typical, diff%) S-->>S: FlightResult(legs=[FlightLeg(...)], emissions=...) end S-->>C: list[FlightResult] C->>C: _serialize_flight_result(flight) Note over C: round-trip: only outbound.emissions serialised C-->>C: dict with optional aircraft/legroom/codeshares/amenities/emissionsPrompt To Fix All With AI
Reviews (1): Last reviewed commit: "feat: expose aircraft, legroom, amenitie..." | Re-trigger Greptile
(2/5) Greptile learns from your feedback when you react with thumbs up/down!
Context used: