Add flight_number field to Flight schema#93
Add flight_number field to Flight schema#93scottyallen wants to merge 1 commit intoAWeirdDev:mainfrom
Conversation
- Add flight_number: Optional[str] = None to Flight dataclass - Extract flight number from span.Xsgmwe in parse_response() - Flight numbers appear as "F9 1230" or "UA 820" format Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe changes add flight number tracking to the flight parsing system by introducing a new optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
fast_flights/core.py (1)
277-280: Type mismatch:stops_fmt = "Unknown"is incompatible withFlight.stops: int.When
ValueErroris raised,stops_fmtis set to the string"Unknown", but theFlightdataclass expectsstopsto be anint. This will cause a type inconsistency when constructingFlight(**fl)on line 301.Consider one of these fixes:
- Use a sentinel integer value (e.g.,
-1) to indicate unknown stops- Update
Flight.stopstoUnion[int, str]orOptional[int]if "Unknown" is a valid semantic value🐛 Proposed fix using sentinel value
try: stops_fmt = 0 if stops == "Nonstop" else int(stops.split(" ", 1)[0]) except ValueError: - stops_fmt = "Unknown" + stops_fmt = -1 # Sentinel for unknown stopsAlternatively, if "Unknown" has semantic meaning, update the schema:
# In schema.py - stops: int + stops: Union[int, str]
Summary
flight_number: Optional[str] = Nonefield to theFlightdataclass in schema.pyContext
The JS data source (decoder.py) already includes flight numbers in its
Flightclass, but the HTML-basedResult.Flightclass in schema.py was missing this field. This PR adds the field for schema consistency.Notes
span.Xsgmweselector, but Google Flights doesn't expose flight numbers in the collapsed list view HTMLdata_source='js')flight_numberdefaults toNoneTest plan
data_source='js'to confirm flight numbers are available🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.