Tags: gedhi/fli
Tags
refactor: harden airport search (Pydantic AirportMatch + import-time … …validation) (punitarani#152) * refactor: harden airport search with Pydantic AirportMatch and import-time validation Breaking API changes to fli.core.airports (1-day-old public API, locking in the right shape before external consumers grow): - AirportMatch is now a frozen Pydantic BaseModel: code: Airport (enum, was str) match_type: Literal["iata_exact","iata_prefix","city","name"] score: float = Field(ge=0, le=100) - match_type "code" was overloaded across two priorities; split into "iata_exact" (exact IATA match, score 100) and "iata_prefix" (prefix match, score 60) so consumers can branch reliably. Defensive hardening: - CITY_AIRPORTS is validated against the Airport enum at import time; a typo (e.g. JKF for JFK) now raises RuntimeError immediately instead of silently producing empty results. The except KeyError: pass guards in priorities 2 and 3 are removed -- they were masking developer bugs. - find_airports MCP tool wraps search_airports in try/except for parity with search_flights / search_dates, returning {success: False, error, query} on failure. Docs and consumers: - Rewrote the misleading CITY_AIRPORTS module comment (the original "city is NOT in the airport name" invariant was false for many entries -- atlanta, denver, seattle, miami, berlin, etc.). - search_airports docstring now documents the 5-priority cascade and score bands. - CLI and MCP consumers updated to use r.code.name (IATA string) since code is now an Airport enum. Tests (+19 net): - tests/core/test_airports.py: rewrote for new shape; added coverage for limit<1, surrounding whitespace, dedup across priorities, priority-3 skip when exact city, monotonic score ordering, position scoring, and AirportMatch frozen / equality / validation behavior. - tests/mcp/test_find_airports.py: new -- MCP tool response shape, success/error envelope, limit capping, no-results. - tests/cli/test_airports.py: new -- CliRunner coverage for table output, --json flag, no-results exit code, --limit. uv.lock: drift correction (0.8.4 -> 0.8.5 to match pyproject.toml). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix(cli): use plain print() for --json output to bypass Rich markup Rich's Console interprets `[` as a markup tag start. In non-TTY environments (CI, pipes), JSON output beginning with `[{` was being parsed as malformed markup and suppressed entirely, leaving stdout empty. CliRunner-based tests caught this with JSONDecodeError on empty stdout. Switching to plain print() bypasses Rich for the machine-readable path, which is the right thing to do for --json anyway. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Add configurable default currency via environment variable and CLI op… …tion (punitarani#123) * fix: make fallback currency configurable instead of hardcoded USD (punitarani#108) When Google Flights does not return a currency in its response, `fli` previously always labeled prices as USD regardless of the user's locale. This produced incorrect results for non-US users (e.g., CAD prices shown as USD). - Read fallback currency from FLI_DEFAULT_CURRENCY env var (default: USD) - Add --currency CLI flag to both `flights` and `dates` commands - Thread default_currency through serialization and display functions - Apply fallback currency consistently in both JSON and rich display - Remove dead _parse_price method (superseded by _parse_price_info) - Migrate tests from deleted method to _parse_price_info - Add tests for currency override behavior https://claude.ai/code/session_01EPvRRhETZaLR8GPo3cfvDd * fix: validate --currency flag and normalize env var to uppercase Add a validate_currency typer callback that rejects values not matching the 3-letter ISO 4217 format. Also normalize FLI_DEFAULT_CURRENCY to uppercase at read time so lowercase env values work correctly. https://claude.ai/code/session_01EPvRRhETZaLR8GPo3cfvDd * simplify: drop env var, use --currency flag as sole config point Remove FLI_DEFAULT_CURRENCY env var and DEFAULT_CURRENCY constant. The --currency CLI flag (defaulting to "USD") is now the single way to configure the fallback currency, keeping the implementation simpler. https://claude.ai/code/session_01EPvRRhETZaLR8GPo3cfvDd --------- Co-authored-by: Claude <noreply@anthropic.com>
Update test dates from 2026 to 2027 (punitarani#110) * Fix hardcoded test dates that are now in the past The tests in test_builders.py used hardcoded date "2026-4-2" which is now past (today is 2026-04-03), causing FlightSegment validation to reject them. Push all hardcoded test dates to 2027-01-15 to avoid this for ~9 months. https://claude.ai/code/session_01Wi2e1qcAHBZzCAQ4rPFkAp * Update uv.lock after dependency sync https://claude.ai/code/session_01Wi2e1qcAHBZzCAQ4rPFkAp * Restore distinct test coverage for date normalization scenarios Fix duplicate assertions introduced in the previous commit: ensure single-digit month+day, single-digit day, and single-digit month each have a unique test case. https://claude.ai/code/session_01Wi2e1qcAHBZzCAQ4rPFkAp --------- Co-authored-by: Claude <noreply@anthropic.com>
Update docs for v0.8.0 (punitarani#87) * Update docs for v0.8.0 - Remove defunct FastAPI server references from CLAUDE.md, AGENTS.md, Makefile - Add missing CLI options to README (--return, --duration, --round, --airlines, --time, --sort) - Update all example dates from 2024/2025 to 2026 across all docs - Fix incorrect round-trip result processing in advanced examples - Add missing LayoverRestrictions import in advanced examples - Expand quickstart example list from 5 to all 11 files - Update mkdocs.yml copyright year and description - Fix MCP HTTP URL trailing slash in AGENTS.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Update docs/examples/advanced.md Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
v0.7.0 (punitarani#27) * Enhance MCP Server Functionality and CLI Improvements This commit introduces significant updates to the MCP server and CLI for flight search: - **MCP Server Enhancements**: - Added `search_dates` tool for finding cheapest travel dates. - Improved parameter handling in `FlightSearchParams` and `DateSearchParams` for better clarity and usability. - Refactored server to streamline request handling and improve error messaging. - **CLI Updates**: - Updated command options to reflect new parameter names and improve user experience. - Enhanced validation and parsing utilities for better error handling. - Improved documentation and examples for MCP server integration. - **Core Utilities**: - Introduced shared parsing and building utilities to reduce code duplication between CLI and MCP. These changes aim to enhance the overall functionality and user experience of the flight search tools. * Refactor CLI Commands and Enhance Flight Search Functionality This commit updates the CLI commands for flight searches, replacing the previous `search` and `cheap` commands with `flights` and `dates`. Key changes include: - **CLI Command Updates**: - Renamed commands to better reflect their functionality. - Updated documentation and examples to align with new command names. - **New Command Implementations**: - Introduced `dates.py` for searching the cheapest travel dates. - Implemented `flights.py` for searching specific flights with enhanced filtering options. - **Testing Enhancements**: - Added comprehensive tests for both new commands to ensure functionality and reliability. These changes aim to improve user experience and streamline the flight search process. * Bump Package Version to 0.7.0 * Format * Add plotext dependency and integrate sparkline chart in date results display This commit introduces the `plotext` library as a new dependency for rendering sparkline charts. The `display_date_results` function is updated to visualize price trends over dates using a sparkline chart, enhancing the user experience by providing a graphical representation of data alongside the existing table format. The chart includes proper labeling and formatting for clarity. * Add retry logic for flight search API calls This commit introduces a new `search_with_retry` function that implements retry logic for the flight search API, utilizing the `tenacity` library. The function attempts to search for flights up to three times with exponential backoff if the initial search returns empty results. This enhancement aims to improve the reliability of flight search results in the face of flaky API responses.
PreviousNext