Google Flights MCP, CLI and Python Library
fix: make every Airport/Airline enum member distinct (OKA, NTL, TRI no longer alias other airports) (#160)
Origo6957822aa07d
diff --git a/fli-js/scripts/generate-enums.ts b/fli-js/scripts/generate-enums.tsindex 1f46e9a..c85d77c 100644--- a/fli-js/scripts/generate-enums.ts+++ b/fli-js/scripts/generate-enums.ts@@ -79,6 +79,61 @@ function toKey(code: string): string {return /^[0-9]/.test(code) ? `_${code}` : code;}+/**+ * Append IATA codes to duplicate names so every emitted name is unique.+ *+ * Mirrors Python's `_disambiguate_names` in `scripts/generate_enums.py`.+ * The TS `Airport`/`Airline` "enums" are keyed by code (`Airport.JFK ===+ * "JFK"`) so they can't collide the way Python's value-keyed `Enum` can —+ * but `AIRPORT_NAMES`/`AIRLINE_NAMES` are still display names shown to+ * users, and those must match the Python package's output exactly.+ * Entries with unique names are left untouched.+ */+function disambiguateNames(rows: Array<[string, string]>): Array<[string, string]> {+ const counts = new Map<string, number>();+ for (const [, name] of rows) counts.set(name, (counts.get(name) ?? 0) + 1);+ const duplicates = new Set([...counts.entries()].filter(([, c]) => c > 1).map(([name]) => name));+ if (duplicates.size === 0) return rows;+ return rows.map(([code, name]) => [code, duplicates.has(name) ? `${name} (${code})` : name]);+}++/**+ * Throw if any sanitized key or final name repeats.+ *+ * Mirrors Python's `_assert_unique`. Must run after {@link disambiguateNames}+ * so it validates exactly what {@link renderEnum} is about to emit as object+ * literal keys (duplicate sanitized codes) and `AIRPORT_NAMES`/`AIRLINE_NAMES`+ * values (duplicate names).+ */+function assertUnique(rows: Array<[string, string]>, typeName: string): void {+ const keyCounts = new Map<string, number>();+ for (const [code] of rows) {+ const key = toKey(code);+ keyCounts.set(key, (keyCounts.get(key) ?? 0) + 1);+ }+ const dupKeys = [...keyCounts.entries()]+ .filter(([, c]) => c > 1)+ .map(([key]) => key)+ .sort();+ if (dupKeys.length > 0) {+ throw new Error(+ `Duplicate sanitized ${typeName} codes after sanitization: ${dupKeys.join(", ")}`,+ );+ }++ const nameCounts = new Map<string, number>();+ for (const [, name] of rows) nameCounts.set(name, (nameCounts.get(name) ?? 0) + 1);+ const dupNames = [...nameCounts.entries()]+ .filter(([, c]) => c > 1)+ .map(([name]) => name)+ .sort();+ if (dupNames.length > 0) {+ throw new Error(+ `Duplicate ${typeName} names remain after disambiguation: ${dupNames.join(", ")}`,+ );+ }+}+function escapeStringLiteral(s: string): string {return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');}@@ -134,6 +189,12 @@ const allianceRows: Array<[string, string]> = [const allAirlines = [...airlines, ...allianceRows];+const disambiguatedAirports = disambiguateNames(airports);+assertUnique(disambiguatedAirports, "Airport");++const disambiguatedAirlines = disambiguateNames(allAirlines);+assertUnique(disambiguatedAirlines, "Airline");+const airportFile = renderEnum("Airport","AIRPORT_NAMES",@@ -142,7 +203,7 @@ const airportFile = renderEnum(** Auto-generated from data/airports.csv — run \`bun run generate:enums\` to refresh.*/`,- airports,+ disambiguatedAirports,);const airlineFile = renderEnum(@@ -153,7 +214,7 @@ const airlineFile = renderEnum(** Auto-generated from data/airlines.csv — run \`bun run generate:enums\` to refresh.*/`,- allAirlines,+ disambiguatedAirlines,);writeFileSync(join(outDir, "airport.ts"), airportFile);diff --git a/fli-js/src/core/airports.ts b/fli-js/src/core/airports.tsindex 1d35e50..ffaad2f 100644--- a/fli-js/src/core/airports.ts+++ b/fli-js/src/core/airports.ts@@ -82,6 +82,17 @@ for (const [city, codes] of Object.entries(CITY_AIRPORTS)) {}}+/**+ * Strip the internal " (CODE)" suffix that keeps duplicate names unique in+ * AIRPORT_NAMES. The code is always returned separately, so users should see+ * the plain name (mirrors Python's `fli.models.display_name`).+ */+export function airportDisplayName(code: string): string {+ const name = AIRPORT_NAMES[code as Airport] ?? code;+ const suffix = ` (${code})`;+ return name.endsWith(suffix) ? name.slice(0, -suffix.length) : name;+}+/*** Search airports by city name, airport name, or IATA code.*@@ -148,25 +159,26 @@ export function searchAirports(query: string, limit = 10): AirportMatch[] {}// 4. Airport name substring match (position-weighted score)- for (const [code, name] of Object.entries(AIRPORT_NAMES)) {+ for (const code of Object.keys(AIRPORT_NAMES)) {if (seen.has(code)) continue;- const nameLower = name.toLowerCase();- const pos = nameLower.indexOf(queryLower);+ // Match on the name users see, not the internal " (CODE)" suffix.+ const displayName = airportDisplayName(code);+ const pos = displayName.toLowerCase().indexOf(queryLower);if (pos !== -1) {const score = 70.0 - pos * 0.1;- results.push({ code: code as Airport, name, match_type: "name", score });+ results.push({ code: code as Airport, name: displayName, match_type: "name", score });seen.add(code);}}// 5. IATA prefix match (≤3-char query)if (queryUpper.length <= 3) {- for (const [code, name] of Object.entries(AIRPORT_NAMES)) {+ for (const code of Object.keys(AIRPORT_NAMES)) {if (seen.has(code)) continue;if (code.startsWith(queryUpper)) {results.push({code: code as Airport,- name,+ name: airportDisplayName(code),match_type: "iata_prefix",score: 60.0,});diff --git a/fli-js/src/models/airline.ts b/fli-js/src/models/airline.tsindex b21ed67..db91a1f 100644--- a/fli-js/src/models/airline.ts+++ b/fli-js/src/models/airline.ts@@ -129,7 +129,7 @@ export const AIRLINE_NAMES: Record<string, string> = {DH: "Douniah Airlines",DI: "Norwegian Air UK",DJ: "AirAsia Japan",- DK: "Thomas Cook Airlines",+ DK: "Thomas Cook Airlines (DK)",DL: "Delta Air Lines",DM: "Arajet",DN: "Norwegian Air Argentina",@@ -435,14 +435,14 @@ export const AIRLINE_NAMES: Record<string, string> = {MQ: "Envoy Air",MR: "Hunnu Air",MS: "EgyptAir",- MT: "Thomas Cook Airlines",+ MT: "Thomas Cook Airlines (MT)",MU: "China Eastern Airlines",MV: "Air Mediterranean",MW: "Mokulele Airlines",MX: "Breeze Airways",MY: "MASwings",MZ: "Amakusa Airlines",- N0: "Norse Atlantic Airways",+ N0: "Norse Atlantic Airways (N0)",N2: "Dagestan Airlines",N3: "Aerolineas Mas",N4: "Nord Wind",@@ -511,7 +511,7 @@ export const AIRLINE_NAMES: Record<string, string> = {P1: "Publiccharters Com",P2: "Airkenya Express",P3: "CargoLogicAir",- P4: "Aerolineas Sosa",+ P4: "Aerolineas Sosa (P4)",P5: "Copa Airlines Colombia",P6: "Pascan Aviation",P8: "SprintAir",@@ -610,7 +610,7 @@ export const AIRLINE_NAMES: Record<string, string> = {RX: "Regent Airways",RY: "Jiangxi Air",RZ: "SANSA Airlines",- S0: "Aerolineas Sosa",+ S0: "Aerolineas Sosa (S0)",S1: "Lufthansa Systems",S2: "Jet Lite",S3: "SBA Airlines",@@ -754,10 +754,10 @@ export const AIRLINE_NAMES: Record<string, string> = {W3: "Arik Air",W4: "LC Péru",W5: "Mahan Airlines",- W6: "Wizz Air",+ W6: "Wizz Air (W6)",W7: "Sayakhat Airlines",W8: "Caribbean Winds Airlines",- W9: "Wizz Air",+ W9: "Wizz Air (W9)",WA: "KLM Cityhopper",WB: "Rwandair",WC: "Islena Airlines",@@ -788,7 +788,7 @@ export const AIRLINE_NAMES: Record<string, string> = {X3: "TUIfly",X4: "Air Excursions",X6: "Airlines Reporting Corp",- X7: "Challenge Aero",+ X7: "Challenge Aero (X7)",X9: "Avion Express",XB: "IATA",XC: "Corendon Airlines",@@ -846,7 +846,7 @@ export const AIRLINE_NAMES: Record<string, string> = {YW: "Air Nostrum",YX: "Republic Airline",YZ: "Alas Uruguay",- Z0: "Norse Atlantic Airways",+ Z0: "Norse Atlantic Airways (Z0)",Z2: "AirAsia Zest",Z3: "PM Air",Z4: "Zagrosjet",@@ -905,11 +905,11 @@ export const AIRLINE_NAMES: Record<string, string> = {_1P: "Travelport Worldspan",_1Q: "Joint Stock Company Ital",_1R: "Bird Information Systems",- _1S: "Sabre",+ _1S: "Sabre (1S)",_1T: "East Line",_1U: "ITA Software",_1V: "Galileo International",- _1W: "Sabre",+ _1W: "Sabre (1W)",_1X: "Branson Air Express",_1Y: "Electronic Data Systems (EDS)",_1Z: "Fantasia Info Network",@@ -989,7 +989,7 @@ export const AIRLINE_NAMES: Record<string, string> = {_4Y: "Discover Airlines",_4Z: "Airlink",_5B: "Bassaka Air",- _5C: "Challenge Aero",+ _5C: "Challenge Aero (5C)",_5D: "Aeroméxico Connect",_5E: "Aero",_5F: "Fly One",diff --git a/fli-js/src/models/airport.ts b/fli-js/src/models/airport.tsindex 661007d..3750ad5 100644--- a/fli-js/src/models/airport.ts+++ b/fli-js/src/models/airport.ts@@ -161,7 +161,7 @@ export const AIRPORT_NAMES: Record<string, string> = {AHU: "Cherif Al Idrissi Airport",AHZ: "L'alpe D'huez Airport",AIA: "Alliance Municipal Airport",- AID: "Anderson Regional Airport",+ AID: "Anderson Regional Airport (AID)",AIE: "Aiome Airport",AIF: "Marcelo Pires Halzhausen Airport",AIG: "Yalinga Airport",@@ -184,7 +184,7 @@ export const AIRPORT_NAMES: Record<string, string> = {AJL: "Lengpui Airport",AJN: "Ouani Airport",AJR: "Arvidsjaur Airport",- AJU: "Santa Maria Airport",+ AJU: "Santa Maria Airport (AJU)",AJY: "Mano Dayak International Airport",AKA: "Ankang Airport",AKB: "Atka Airport",@@ -251,7 +251,7 @@ export const AIRPORT_NAMES: Record<string, string> = {AMZ: "Ardmore Airport",ANB: "Anniston Regional Airport",ANC: "Ted Stevens Anchorage International Airport",- AND: "Anderson Regional Airport",+ AND: "Anderson Regional Airport (AND)",ANE: "Angers-Loire Airport",ANF: "Cerro Moreno Airport",ANG: "Angouleme-Brie-Champniers Airport",@@ -636,7 +636,7 @@ export const AIRPORT_NAMES: Record<string, string> = {BHP: "Bhojpur Airport",BHQ: "Broken Hill Airport",BHR: "Bharatpur Airport",- BHS: "Bathurst Airport",+ BHS: "Bathurst Airport (BHS)",BHU: "Bhavnagar Airport",BHV: "Bahawalpur Airport",BHW: "Bhagatanwala Airport",@@ -818,7 +818,7 @@ export const AIRPORT_NAMES: Record<string, string> = {BQL: "Boulia Airport",BQN: "Rafael Hernandez Airport",BQO: "Bouna Airport",- BQQ: "Barra Airport",+ BQQ: "Barra Airport (BQQ)",BQS: "Ignatyevo Airport",BQT: "Brest Airport",BQU: "J F Mitchell Airport",@@ -835,7 +835,7 @@ export const AIRPORT_NAMES: Record<string, string> = {BRN: "Bern Belp Airport",BRO: "Brownsville/South Padre Island International Airport",BRQ: "Brno-Turany Airport",- BRR: "Barra Airport",+ BRR: "Barra Airport (BRR)",BRS: "Bristol International Airport",BRT: "Bathurst Island Airport",BRU: "Brussels Airport",@@ -844,14 +844,14 @@ export const AIRPORT_NAMES: Record<string, string> = {BRY: "Samuels Field",BSA: "Bosaso Airport",BSB: "Presidente Juscelino Kubistschek International Airport",- BSC: "Jose Celestino Mutis Airport",+ BSC: "Jose Celestino Mutis Airport (BSC)",BSD: "Baoshan Yunduan Airport",BSE: "Sematan Airport",BSF: "Bradshaw Army Airfield",BSG: "Bata Airport",BSJ: "Bairnsdale Airport",BSK: "Biskra Airport",- BSL: "EuroAirport Basel-Mulhouse-Freiburg Airport",+ BSL: "EuroAirport Basel-Mulhouse-Freiburg Airport (BSL)",BSM: "Bishe Kola Air Base",BSN: "Bossangoa Airport",BSO: "Basco Airport",@@ -946,7 +946,7 @@ export const AIRPORT_NAMES: Record<string, string> = {BWQ: "Brewarrina Airport",BWT: "Wynyard Airport",BWU: "Sydney Bankstown Airport",- BWW: "Las Brujas Airport",+ BWW: "Las Brujas Airport (BWW)",BXA: "George R Carr Memorial Air Field",BXB: "Babo Airport",BXD: "Bade Airport",@@ -983,7 +983,7 @@ export const AIRPORT_NAMES: Record<string, string> = {BYT: "Bantry Aerodrome",BYU: "Bayreuth Airport",BYW: "Blakely Island Airport",- BZA: "San Pedro Airport",+ BZA: "San Pedro Airport (BZA)",BZC: "Umberto Modiano Airport",BZD: "Balranald Airport",BZE: "Philip S. W. Goldson International Airport",@@ -1248,7 +1248,7 @@ export const AIRPORT_NAMES: Record<string, string> = {CLR: "Cliff Hatfield Memorial Airport",CLS: "Chehalis-Centralia Airport",CLT: "Charlotte/Douglas International Airport",- CLU: "Columbus Municipal Airport",+ CLU: "Columbus Municipal Airport (CLU)",CLV: "Caldas Novas Airport",CLW: "Clearwater Executive Airport",CLX: "Clorinda Airport",@@ -1352,7 +1352,7 @@ export const AIRPORT_NAMES: Record<string, string> = {CQW: "Wulong Chongqing Xiannvshan Airport",CRA: "Craiova Airport",CRB: "Collarenebri Airport",- CRC: "Santa Ana Airport",+ CRC: "Santa Ana Airport (CRC)",CRD: "General E. Mosconi Airport",CRE: "Grand Strand Airport",CRF: "Carnot Airport",@@ -1429,7 +1429,7 @@ export const AIRPORT_NAMES: Record<string, string> = {CUP: "General Francisco Bermudez Airport",CUQ: "Coen Airport",CUR: "Hato International Airport",- CUS: "Columbus Municipal Airport",+ CUS: "Columbus Municipal Airport (CUS)",CUT: "Cutral-Co Airport",CUU: "General Roberto Fierro Villalobos International Airport",CUV: "Casigua El Cubo Airport",@@ -1501,7 +1501,7 @@ export const AIRPORT_NAMES: Record<string, string> = {CZO: "Chistochina Airport",CZS: "Cruzeiro do Sul Airport",CZT: "Dimmit County Airport",- CZU: "Las Brujas Airport",+ CZU: "Las Brujas Airport (CZU)",CZX: "Changzhou Airport",CZY: "Cluny Airport",DAA: "Davison Army Air Field",@@ -1509,7 +1509,7 @@ export const AIRPORT_NAMES: Record<string, string> = {DAC: "Dhaka / Hazrat Shahjalal International Airport",DAD: "Da Nang International Airport",DAG: "Barstow-Daggett Airport",- DAK: "Dakhla Airport",+ DAK: "Dakhla Airport (DAK)",DAL: "Dallas Love Field",DAM: "Damascus International Airport",DAN: "Danville Regional Airport",@@ -1854,7 +1854,7 @@ export const AIRPORT_NAMES: Record<string, string> = {ELL: "Ellisras Matimba Airport",ELM: "Elmira/Corning Regional Airport",ELN: "Bowers Field",- ELO: "El Dorado Airport",+ ELO: "El Dorado Airport (ELO)",ELP: "El Paso International Airport",ELQ: "Gassim Airport",ELS: "Ben Schoeman Airport",@@ -1893,7 +1893,7 @@ export const AIRPORT_NAMES: Record<string, string> = {EOH: "Enrique Olaya Herrera Airport",EOI: "Eday Airport",EOK: "Keokuk Municipal Airport",- EOR: "El Dorado Airport",+ EOR: "El Dorado Airport (EOR)",EOS: "Neosho Hugh Robinson Airport",EOZ: "Elorza Airport",EPA: "El Palomar Airport",@@ -1947,7 +1947,7 @@ export const AIRPORT_NAMES: Record<string, string> = {ETZ: "Metz-Nancy-Lorraine Airport",EUA: "Kaufana Airport",EUC: "Eucla Airport",- EUE: "Eureka Airport",+ EUE: "Eureka Airport (EUE)",EUF: "Weedon Field",EUG: "Mahlon Sweet Field",EUM: "Neumunster Airport",@@ -1988,7 +1988,7 @@ export const AIRPORT_NAMES: Record<string, string> = {FAH: "Farah Airport",FAI: "Fairbanks International Airport",FAM: "Farmington Regional Airport",- FAO: "Faro Airport",+ FAO: "Faro Airport (FAO)",FAQ: "Frieda River Airport",FAR: "Hector International Airport",FAT: "Fresno Yosemite International Airport",@@ -2017,7 +2017,7 @@ export const AIRPORT_NAMES: Record<string, string> = {FDF: "Martinique Aime Cesaire International Airport",FDH: "Friedrichshafen Airport",FDK: "Frederick Municipal Airport",- FDO: "San Fernando Airport",+ FDO: "San Fernando Airport (FDO)",FDR: "Frederick Regional Airport",FDU: "Bandundu Airport",FDY: "Findlay Airport",@@ -2036,7 +2036,7 @@ export const AIRPORT_NAMES: Record<string, string> = {FFL: "Fairfield Municipal Airport",FFM: "Fergus Falls Regional Airport",FFO: "Wright-Patterson Afb Airport",- FFT: "Capital City Airport",+ FFT: "Capital City Airport (FFT)",FFU: "Futaleufu Airport",FGD: "Fderik Airport",FGI: "Fagali'i Airport",@@ -2415,7 +2415,7 @@ export const AIRPORT_NAMES: Record<string, string> = {GSE: "Gothenburg City Airport",GSH: "Goshen Municipal Airport",GSI: "Grand-Santi Airport",- GSJ: "San Jose Airport",+ GSJ: "San Jose Airport (GSJ)",GSM: "Dayrestan Airport",GSN: "Mount Gunson Airport",GSO: "Piedmont Triad International Airport",@@ -2485,7 +2485,7 @@ export const AIRPORT_NAMES: Record<string, string> = {GXY: "Greeley-Weld County Airport",GYA: "Capitan de Av. Emilio Beltran Airport",GYD: "Heydar Aliyev International Airport",- GYE: "Simon Bolivar International Airport",+ GYE: "Simon Bolivar International Airport (GYE)",GYG: "Magan Airport",GYI: "Gisenyi Airport",GYL: "Argyle Airport",@@ -2515,7 +2515,7 @@ export const AIRPORT_NAMES: Record<string, string> = {HAN: "Noi Bai International Airport",HAO: "Butler County Regional/Hogan Field",HAQ: "Hanimaadhoo International Airport",- HAR: "Capital City Airport",+ HAR: "Capital City Airport (HAR)",HAS: "Hail Airport",HAT: "Heathlands Airport",HAU: "Haugesund Airport",@@ -2577,7 +2577,7 @@ export const AIRPORT_NAMES: Record<string, string> = {HGH: "Hangzhou Xiaoshan International Airport",HGI: "Donyi Polo Airport",HGL: "Helgoland-Dune Airport",- HGN: "Mae Hong Son Airport",+ HGN: "Mae Hong Son Airport (HGN)",HGO: "Korhogo Airport",HGR: "Hagerstown Regional/Richard A Henson Field",HGS: "Hastings Airport",@@ -3037,7 +3037,7 @@ export const AIRPORT_NAMES: Record<string, string> = {JBK: "Qitai Jiangbulake Airport",JBQ: "La Isabela International Airport",JBR: "Jonesboro Municipal Airport",- JCB: "Santa Terezinha Airport",+ JCB: "Santa Terezinha Airport (JCB)",JCI: "New Century Aircenter Airport",JCK: "Julia Creek Airport",JCL: "Ceske Budejovice Airport",@@ -3680,7 +3680,7 @@ export const AIRPORT_NAMES: Record<string, string> = {LGL: "Long Lellang Airport",LGO: "Langeoog Airport",LGQ: "Nueva Loja Airport",- LGR: "Cochrane Airport",+ LGR: "Cochrane Airport (LGR)",LGS: "Comodoro D.R. Salomon Airport",LGT: "La Gaviota Airport",LGU: "Logan-Cache Airport",@@ -3733,13 +3733,13 @@ export const AIRPORT_NAMES: Record<string, string> = {LKN: "Leknes Airport",LKO: "Chaudhary Charan Singh International Airport",LKP: "Lake Placid Airport",- LKV: "Lake County Airport",+ LKV: "Lake County Airport (LKV)",LKW: "Lekhwair Airport",LKY: "Lake Manyara Airport",LKZ: "RAF Lakenheath",LLA: "Lulea Airport",LLB: "Qiannan Libo Airport",- LLE: "Riverside Airport",+ LLE: "Riverside Airport (LLE)",LLF: "Lingling Airport",LLG: "Chillagoe Airport",LLI: "Lalibella Airport",@@ -3784,7 +3784,7 @@ export const AIRPORT_NAMES: Record<string, string> = {LNY: "Lanai Airport",LNZ: "Linz Airport",LOA: "Lorraine Airport",- LOB: "San Rafael Airport",+ LOB: "San Rafael Airport (LOB)",LOC: "Lock Airport",LOD: "Longana Airport",LOE: "Loei Airport",@@ -3841,7 +3841,7 @@ export const AIRPORT_NAMES: Record<string, string> = {LRV: "Gran Roque Airport",LSA: "Losuia Airport",LSB: "Lordsburg Municipal Airport",- LSC: "La Florida Airport",+ LSC: "La Florida Airport (LSC)",LSE: "La Crosse Regional Airport",LSF: "Lawson Army Air Field (Fort Benning) Airport",LSG: "Leshan Airport (under construction, unknown coordinates)",@@ -3933,7 +3933,7 @@ export const AIRPORT_NAMES: Record<string, string> = {LXR: "Luxor International Airport",LXS: "Limnos Airport",LXU: "Lukulu Airport",- LXV: "Lake County Airport",+ LXV: "Lake County Airport (LXV)",LYA: "Luoyang Airport",LYB: "Edward Bodden Airfield",LYC: "Lycksele Airport",@@ -4043,7 +4043,7 @@ export const AIRPORT_NAMES: Record<string, string> = {MDQ: "Astor Piazzola International Airport",MDS: "Middle Caicos Airport",MDT: "Harrisburg International Airport",- MDU: "Mendi Airport",+ MDU: "Mendi Airport (MDU)",MDW: "Chicago Midway International Airport",MDX: "Mercedes Airport",MDY: "Henderson Field",@@ -4203,7 +4203,7 @@ export const AIRPORT_NAMES: Record<string, string> = {MLE: "Velana International Airport",MLF: "Milford Municipal/Ben And Judy Briscoe Field",MLG: "Abdul Rachman Saleh Airport",- MLH: "EuroAirport Basel-Mulhouse-Freiburg Airport",+ MLH: "EuroAirport Basel-Mulhouse-Freiburg Airport (MLH)",MLI: "Quad Cities International Airport",MLJ: "Baldwin County Regional Airport",MLK: "Malta Airport",@@ -4279,7 +4279,7 @@ export const AIRPORT_NAMES: Record<string, string> = {MOM: "Letfotar Airport",MON: "Mount Cook Airport",MOO: "Moomba Airport",- MOP: "Mount Pleasant Municipal Airport",+ MOP: "Mount Pleasant Municipal Airport (MOP)",MOQ: "Morondava Airport",MOR: "Moore-Murrell Airport",MOS: "Moses Point Airport",@@ -4303,7 +4303,7 @@ export const AIRPORT_NAMES: Record<string, string> = {MPV: "Edward F Knapp State Airport",MPW: "Mariupol International Airport",MPY: "Maripasoula Airport",- MPZ: "Mount Pleasant Municipal Airport",+ MPZ: "Mount Pleasant Municipal Airport (MPZ)",MQA: "Mandora Airport",MQB: "Macomb Municipal Airport",MQC: "Miquelon Airport",@@ -4320,7 +4320,7 @@ export const AIRPORT_NAMES: Record<string, string> = {MQQ: "Moundou Airport",MQS: "Mustique Airport",MQT: "Marquette/Sawyer Regional Airport",- MQU: "Jose Celestino Mutis Airport",+ MQU: "Jose Celestino Mutis Airport (MQU)",MQW: "Telfair-Wheeler Airport",MQX: "Mekele Airport",MQY: "Smyrna Airport",@@ -4527,7 +4527,7 @@ export const AIRPORT_NAMES: Record<string, string> = {NAC: "Naracoorte Airport",NAE: "Natitingou Airport",NAG: "Dr. Babasaheb Ambedkar International Airport",- NAH: "Naha Airport",+ NAH: "Naha Airport (NAH)",NAI: "Annai Airport",NAJ: "Nakhchivan Airport",NAK: "Nakhon Ratchasima Airport",@@ -4560,11 +4560,11 @@ export const AIRPORT_NAMES: Record<string, string> = {NCH: "Nachingwea Airport",NCI: "Necocli Airport",NCJ: "Sunchales Aeroclub Airport",- NCL: "Newcastle Airport",+ NCL: "Newcastle Airport (NCL)",NCN: "Chenega Bay Airport",NCO: "Quonset State Airport",NCR: "San Carlos",- NCS: "Newcastle Airport",+ NCS: "Newcastle Airport (NCS)",NCT: "Guanacaste Airport",NCU: "Nukus Airport",NCY: "Annecy-Haute-Savoie-Mont Blanc Airport",@@ -4576,7 +4576,7 @@ export const AIRPORT_NAMES: Record<string, string> = {NDG: "Qiqihar Sanjiazi Airport",NDJ: "N'Djamena International Airport",NDL: "N'Dele Airport",- NDM: "Mendi Airport",+ NDM: "Mendi Airport (NDM)",NDR: "Nador International Airport",NDS: "Sandstone Airport",NDU: "Rundu Airport",@@ -4667,7 +4667,7 @@ export const AIRPORT_NAMES: Record<string, string> = {NMR: "Nappa Merrie Airport",NMS: "Namsang Airport",NNA: "Kenitra Airport",- NNB: "Santa Ana Airport",+ NNB: "Santa Ana Airport (NNB)",NNG: "Nanning Wuxu Airport",NNI: "Namutoni Airport",NNK: "Naknek Airport",@@ -4682,7 +4682,7 @@ export const AIRPORT_NAMES: Record<string, string> = {NOB: "Nosara Airport",NOC: "Ireland West Knock Airport",NOD: "Norden-Norddeich Airport",- NOG: "Nogales International Airport",+ NOG: "Nogales International Airport (NOG)",NOJ: "Noyabrsk Airport",NOK: "Xavantina Airport",NON: "Nonouti Airport",@@ -4740,7 +4740,7 @@ export const AIRPORT_NAMES: Record<string, string> = {NTG: "Nantong Airport",NTI: "Stenkol Airport",NTJ: "Sanpete County Regional Airport",- NTL: "Newcastle Airport",+ NTL: "Newcastle Airport (NTL)",NTN: "Normanton Airport",NTO: "Agostinho Neto Airport",NTQ: "Noto Airport",@@ -4879,7 +4879,7 @@ export const AIRPORT_NAMES: Record<string, string> = {OIR: "Okushiri Airport",OIT: "Oita Airport",OJC: "Johnson County Executive Airport",- OKA: "Naha Airport",+ OKA: "Naha Airport (OKA)",OKC: "Okc Will Rogers International Airport",OKD: "Okadama Airport",OKE: "Okierabu Airport",@@ -4912,8 +4912,8 @@ export const AIRPORT_NAMES: Record<string, string> = {OLN: "Lago Musters Airport",OLO: "Olomouc Glider Airport",OLP: "Olympic Dam Airport",- OLS: "Nogales International Airport",- OLU: "Columbus Municipal Airport",+ OLS: "Nogales International Airport (OLS)",+ OLU: "Columbus Municipal Airport (OLU)",OLV: "Olive Branch/Taylor Field",OLY: "Olney-Noble Airport",OLZ: "Olyokminsk Airport",@@ -5164,7 +5164,7 @@ export const AIRPORT_NAMES: Record<string, string> = {PFQ: "Parsabade Moghan Airport",PFR: "Ilebo Airport",PGA: "Page Municipal Airport",- PGC: "Grant County Airport",+ PGC: "Grant County Airport (PGC)",PGD: "Punta Gorda Airport",PGF: "Perpignan-Rivesaltes (Llabanere) Airport",PGH: "Pantnagar Airport",@@ -5260,9 +5260,9 @@ export const AIRPORT_NAMES: Record<string, string> = {PLV: "Poltava International Airport",PLW: "Mutiara Airport",PLX: "Semey International Airport",- PLY: "Plymouth Municipal Airport",+ PLY: "Plymouth Municipal Airport (PLY)",PLZ: "Port Elizabeth Airport",- PMA: "Pemba Airport",+ PMA: "Pemba Airport (PMA)",PMB: "Pembina Municipal Airport",PMC: "El Tepual Airport",PMD: "Palmdale Usaf Plant 42 Airport",@@ -5309,7 +5309,7 @@ export const AIRPORT_NAMES: Record<string, string> = {POH: "Pocahontas Municipal Airport",POI: "Capitan Nicolas Rojas Airport",POJ: "Patos de Minas Airport",- POL: "Pemba Airport",+ POL: "Pemba Airport (POL)",POM: "Port Moresby Jacksons International Airport",PON: "Poptun Airport",POO: "Pocos de Caldas Airport",@@ -5372,7 +5372,7 @@ export const AIRPORT_NAMES: Record<string, string> = {PRZ: "Prineville Airport",PSA: "Pisa / San Giusto - Galileo Galilei International Airport",PSB: "Mid-State Airport",- PSC: "Tri-Cities Airport",+ PSC: "Tri-Cities Airport (PSC)",PSD: "Port Said Airport",PSE: "Mercedita Airport",PSF: "Pittsfield Municipal Airport",@@ -5469,11 +5469,11 @@ export const AIRPORT_NAMES: Record<string, string> = {PYH: "Cacique Aramare Airport",PYJ: "Polyarny Airport",PYK: "Payam Airport",- PYM: "Plymouth Municipal Airport",+ PYM: "Plymouth Municipal Airport (PYM)",PYO: "Putumayo Airport",PYR: "Andravida Airport",PYS: "Paradise Skypark Airport",- PYY: "Mae Hong Son Airport",+ PYY: "Mae Hong Son Airport (PYY)",PYZ: "Pias Airport",PZA: "Paz De Ariporo Airport",PZB: "Pietermaritzburg Airport",@@ -5557,7 +5557,7 @@ export const AIRPORT_NAMES: Record<string, string> = {RAH: "Rafha Domestic Airport",RAI: "Praia International Airport",RAK: "Menara Airport",- RAL: "Riverside Airport",+ RAL: "Riverside Airport (RAL)",RAM: "Ramingining Airport",RAN: "Ravenna Airport",RAO: "Leite Lopes Airport",@@ -5660,7 +5660,7 @@ export const AIRPORT_NAMES: Record<string, string> = {RHP: "Ramechhap Airport",RHT: "Alxa Right Banner Badanjilin Airport",RHV: "Reid-Hillview Of Santa Clara County Airport",- RIA: "Santa Maria Airport",+ RIA: "Santa Maria Airport (RIA)",RIB: "Capitan Av. Selin Zeitun Lopez Airport",RIC: "Richmond International Airport",RID: "Richmond Municipal Airport",@@ -5769,7 +5769,7 @@ export const AIRPORT_NAMES: Record<string, string> = {RRR: "Raroia Airport",RRS: "Røros Airport",RRT: "Warroad International Memorial Airport",- RSA: "Santa Rosa Airport",+ RSA: "Santa Rosa Airport (RSA)",RSB: "Roseberth Airport",RSD: "Rock Sound Airport",RSH: "Russian Mission Airport",@@ -5830,7 +5830,7 @@ export const AIRPORT_NAMES: Record<string, string> = {RYK: "Shaikh Zaid Airport",RYN: "Royan-Medis Airport",RYO: "28 De Noviembre Airport",- RZA: "Santa Cruz Airport",+ RZA: "Santa Cruz Airport (RZA)",RZE: "Rzeszow-Jasionka Airport",RZN: "Turlatovo Airport",RZP: "Cesar Lim Rodriguez Airport",@@ -5940,7 +5940,7 @@ export const AIRPORT_NAMES: Record<string, string> = {SFB: "Orlando Sanford International Airport",SFC: "St-Francois Airport",SFD: "San Fernando De Apure Airport",- SFE: "San Fernando Airport",+ SFE: "San Fernando Airport (SFE)",SFF: "Felts Field",SFG: "L'Esperance Airport",SFH: "San Felipe International Airport",@@ -5964,7 +5964,7 @@ export const AIRPORT_NAMES: Record<string, string> = {SGI: "Mushaf Air Base",SGL: "Sangley Point Air Base",SGN: "Tan Son Nhat International Airport",- SGO: "St George Airport",+ SGO: "St George Airport (SGO)",SGP: "Shay Gap Airport",SGQ: "Sanggata Airport",SGR: "Sugar Land Regional Airport",@@ -5989,7 +5989,7 @@ export const AIRPORT_NAMES: Record<string, string> = {SHM: "Nanki Shirahama Airport",SHN: "Sanderson Field",SHO: "King Mswati III Intl",- SHQ: "Southport Airport",+ SHQ: "Southport Airport (SHQ)",SHR: "Sheridan County Airport",SHS: "Shashi Airport",SHT: "Shepparton Airport",@@ -6027,7 +6027,7 @@ export const AIRPORT_NAMES: Record<string, string> = {SJC: "Norman Y Mineta San Jose International Airport",SJD: "Los Cabos International Airport",SJE: "Jorge E. Gonzalez Torres Airport",- SJI: "San Jose Airport",+ SJI: "San Jose Airport (SJI)",SJJ: "Sarajevo International Airport",SJK: "Professor Urbano Ernesto Stumpf Airport",SJL: "Sao Gabriel da Cachoeira Airport",@@ -6068,7 +6068,7 @@ export const AIRPORT_NAMES: Record<string, string> = {SLD: "Sliac Airport",SLE: "Mcnary Field",SLF: "Sulayel Airport",- SLG: "Smith Field",+ SLG: "Smith Field (SLG)",SLH: "Sola Airport",SLI: "Solwesi Airport",SLJ: "Solomon Airport",@@ -6087,12 +6087,12 @@ export const AIRPORT_NAMES: Record<string, string> = {SLX: "Salt Cay Airport",SLY: "Salekhard Airport",SLZ: "Marechal Cunha Machado International Airport",- SMA: "Santa Maria Airport",+ SMA: "Santa Maria Airport (SMA)",SMB: "Franco Bianco Airport",- SMD: "Smith Field",+ SMD: "Smith Field (SMD)",SME: "Lake Cumberland Regional Airport",SMF: "Sacramento International Airport",- SMG: "Santa Maria Airport",+ SMG: "Santa Maria Airport (SMG)",SMI: "Samos Airport",SMK: "St Michael Airport",SML: "Stella Maris Airport",@@ -6100,7 +6100,7 @@ export const AIRPORT_NAMES: Record<string, string> = {SMN: "Lemhi County Airport",SMO: "Santa Monica Municipal Airport",SMQ: "Sampit(Hasan) Airport",- SMR: "Simon Bolivar International Airport",+ SMR: "Simon Bolivar International Airport (SMR)",SMS: "Sainte Marie Airport",SMU: "Sheep Mountain Airport",SMV: "Samedan Airport",@@ -6130,7 +6130,7 @@ export const AIRPORT_NAMES: Record<string, string> = {SNW: "Thandwe Airport",SNX: "Semnan Airport",SNY: "Sidney Municipal/Lloyd W Carr Field",- SNZ: "Santa Cruz Airport",+ SNZ: "Santa Cruz Airport (SNZ)",SOB: "Sarmellek International Airport",SOC: "Adi Sumarmo Wiryokusumo Airport",SOD: "Sorocaba Airport",@@ -6167,7 +6167,7 @@ export const AIRPORT_NAMES: Record<string, string> = {SPU: "Split Airport",SPW: "Spencer Municipal Airport",SPX: "Sphinx International Airport",- SPY: "San Pedro Airport",+ SPY: "San Pedro Airport (SPY)",SPZ: "Springdale Municipal Airport",SQA: "Santa Ynez/Kunkle Field",SQC: "Southern Cross Airport",@@ -6187,12 +6187,12 @@ export const AIRPORT_NAMES: Record<string, string> = {SQX: "Sao Miguel do Oeste Airport",SQY: "Sao Lourenco do Sul Airport",SQZ: "RAF Scampton",- SRA: "Santa Rosa Airport",+ SRA: "Santa Rosa Airport (SRA)",SRB: "Santa Rosa De Yacuma Airport",SRC: "Searcy Regional Airport",SRD: "San Ramon Airport",SRE: "Alcantarí International Airport",- SRF: "San Rafael Airport",+ SRF: "San Rafael Airport (SRF)",SRG: "Achmad Yani Airport",SRH: "Sarh Airport",SRJ: "Capitan Av. German Quiroga G. Airport",@@ -6228,7 +6228,7 @@ export const AIRPORT_NAMES: Record<string, string> = {STC: "St Cloud Regional Airport",STD: "Mayor Buenaventura Vivas International Airport",STE: "Stevens Point Municipal Airport",- STG: "St George Airport",+ STG: "St George Airport (STG)",STH: "Strathmore Airport",STI: "Cibao International Airport",STJ: "Rosecrans Memorial Airport",@@ -6245,7 +6245,7 @@ export const AIRPORT_NAMES: Record<string, string> = {STW: "Stavropol Shpakovskoye Airport",STX: "Henry E Rohlsen Airport",STY: "Nueva Hesperides International Airport",- STZ: "Santa Terezinha Airport",+ STZ: "Santa Terezinha Airport (STZ)",SUA: "Witham Field",SUB: "Juanda International Airport",SUD: "Stroud Municipal Airport",@@ -6271,7 +6271,7 @@ export const AIRPORT_NAMES: Record<string, string> = {SUY: "Suntar Airport",SVA: "Savoonga Airport",SVB: "Sambava Airport",- SVC: "Grant County Airport",+ SVC: "Grant County Airport (SVC)",SVD: "Argyle International Airport",SVE: "Susanville Municipal Airport",SVF: "Save Airport",@@ -6415,7 +6415,7 @@ export const AIRPORT_NAMES: Record<string, string> = {TCL: "Tuscaloosa Ntl Airport",TCM: "Mcchord Field (Joint Base Lewis-Mcchord) Airport",TCN: "Tehuacan Airport",- TCO: "La Florida Airport",+ TCO: "La Florida Airport (TCO)",TCP: "Taba International Airport",TCQ: "Coronel FAP Carlos Ciriani Santa Rosa International Airport",TCR: "Tuticorin Southwest Airport",@@ -6683,7 +6683,7 @@ export const AIRPORT_NAMES: Record<string, string> = {TRF: "Sandefjord Airport Torp",TRG: "Tauranga Airport",TRH: "Trona Airport",- TRI: "Tri-Cities Airport",+ TRI: "Tri-Cities Airport (TRI)",TRK: "Juwata Airport",TRL: "Terrell Municipal Airport",TRM: "Jacqueline Cochran Regional Airport",@@ -6763,7 +6763,7 @@ export const AIRPORT_NAMES: Record<string, string> = {TWB: "Toowoomba Airport",TWC: "Tumxuk Tangwangcheng Airport",TWD: "Jefferson County International Airport",- TWE: "Taylor Airport",+ TWE: "Taylor Airport (TWE)",TWF: "Joslin Field/Magic Valley Regional Airport",TWU: "Tawau Airport",TWZ: "Pukaki Airport",@@ -6786,7 +6786,7 @@ export const AIRPORT_NAMES: Record<string, string> = {TYR: "Tyler Pounds Regional Airport",TYS: "Mc Ghee Tyson Airport",TYT: "Treinta y Tres Airport",- TYZ: "Taylor Airport",+ TYZ: "Taylor Airport (TYZ)",TZC: "Tuscola Area Airport",TZL: "Tuzla International Airport",TZR: "Taszar Air Base",@@ -6823,7 +6823,7 @@ export const AIRPORT_NAMES: Record<string, string> = {UDI: "Ten. Cel. Aviador Cesar Bombonato Airport",UDJ: "Uzhhorod International Airport",UDR: "Maharana Pratap Airport",- UEE: "Queenstown Airport",+ UEE: "Queenstown Airport (UEE)",UEL: "Quelimane Airport",UEN: "Urengoy Airport",UEO: "Kumejima Airport",@@ -6940,7 +6940,7 @@ export const AIRPORT_NAMES: Record<string, string> = {UTR: "Uttaradit Airport",UTS: "Ust-Tsylma Airport",UTT: "K. D. Matanzima Airport",- UTW: "Queenstown Airport",+ UTW: "Queenstown Airport (UTW)",UUA: "Bugulma Airport",UUD: "Ulan-Ude Airport (Mukhino)",UUK: "Ugnu-Kuparuk Airport",@@ -7025,7 +7025,7 @@ export const AIRPORT_NAMES: Record<string, string> = {VIH: "Rolla Ntl Airport",VII: "Vinh Airport",VIJ: "Virgin Gorda Airport",- VIL: "Dakhla Airport",+ VIL: "Dakhla Airport (VIL)",VIN: "Havryshivka Vinnytsia International Airport",VIP: "Payerne Airport",VIQ: "Viqueque Airport",@@ -7284,12 +7284,12 @@ export const AIRPORT_NAMES: Record<string, string> = {WTZ: "Whitianga Airport",WUA: "Wuhai Airport",WUD: "Wudinna Airport",- WUG: "Wau Airport",+ WUG: "Wau Airport (WUG)",WUH: "Wuhan Tianhe International Airport",WUI: "Murrin Murrin Airport",WUN: "Wiluna Airport",WUS: "Nanping Wuyishan Airport",- WUU: "Wau Airport",+ WUU: "Wau Airport (WUU)",WUX: "Sunan Shuofang International Airport",WUZ: "Wuzhou Xijiang Airport",WVB: "Walvis Bay Airport",@@ -7432,7 +7432,7 @@ export const AIRPORT_NAMES: Record<string, string> = {YCK: "Colville Lake Airport",YCL: "Charlo Airport",YCM: "St. Catharines Niagara District Airport",- YCN: "Cochrane Airport",+ YCN: "Cochrane Airport (YCN)",YCO: "Kugluktuk Airport",YCQ: "Chetwynd Airport",YCR: "Cross Lake (Charlie Sinclair Memorial) Airport",@@ -7445,7 +7445,7 @@ export const AIRPORT_NAMES: Record<string, string> = {YDA: "Dawson City Airport",YDB: "Burwash Airport",YDC: "Drayton Valley Industrial Airport",- YDF: "Deer Lake Airport",+ YDF: "Deer Lake Airport (YDF)",YDG: "Digby / Annapolis Regional Airport",YDJ: "Hatchet Lake Airport",YDL: "Dease Lake Airport",@@ -7470,7 +7470,7 @@ export const AIRPORT_NAMES: Record<string, string> = {YER: "Fort Severn Airport",YES: "Yasouj Airport",YET: "Edson Airport",- YEU: "Eureka Airport",+ YEU: "Eureka Airport (YEU)",YEV: "Inuvik (Mike Zubko) Airport",YEY: "Amos Magny Airport",YFA: "Fort Albany Airport",@@ -7506,7 +7506,7 @@ export const AIRPORT_NAMES: Record<string, string> = {YHD: "Dryden Regional Airport",YHE: "Hope Airport",YHF: "Hearst Rene Fontaine Municipal Airport",- YHG: "Charlottetown Airport",+ YHG: "Charlottetown Airport (YHG)",YHI: "Ulukhaktok Holman Airport",YHJ: "Nanchang Yaohu Airport",YHK: "Gjoa Haven Airport",@@ -7623,7 +7623,7 @@ export const AIRPORT_NAMES: Record<string, string> = {YPC: "Paulatuk (Nora Aliqatchialuk Ruben) Airport",YPD: "Parry Sound Area Municipal Airport",YPE: "Peace River Airport",- YPG: "Southport Airport",+ YPG: "Southport Airport (YPG)",YPH: "Inukjuak Airport",YPJ: "Aupaluk Airport",YPK: "Pitt Meadows Airport",@@ -7726,7 +7726,7 @@ export const AIRPORT_NAMES: Record<string, string> = {YVR: "Vancouver International Airport",YVT: "Buffalo Narrows Airport",YVV: "Wiarton Airport",- YVZ: "Deer Lake Airport",+ YVZ: "Deer Lake Airport (YVZ)",YWA: "Petawawa Airport",YWB: "Kangiqsujuaq (Wakeham Bay) Airport",YWG: "Winnipeg James Armstrong Richardson International Airport",@@ -7759,7 +7759,7 @@ export const AIRPORT_NAMES: Record<string, string> = {YYD: "Smithers Airport",YYE: "Fort Nelson Airport",YYF: "Penticton Airport",- YYG: "Charlottetown Airport",+ YYG: "Charlottetown Airport (YYG)",YYH: "Taloyoak Airport",YYJ: "Victoria International Airport",YYL: "Lynn Lake Airport",@@ -7798,7 +7798,7 @@ export const AIRPORT_NAMES: Record<string, string> = {ZAT: "Zhaotong Airport",ZAZ: "Zaragoza Air Base",ZBE: "Zabreh Ostrava Airport",- ZBF: "Bathurst Airport",+ ZBF: "Bathurst Airport (ZBF)",ZBL: "Thangool (Biloela) Airport",ZBM: "Bromont (Roland Desourdy) Airport",ZBO: "Bowen Airport",@@ -7810,7 +7810,7 @@ export const AIRPORT_NAMES: Record<string, string> = {ZEL: "Bella Bella (Campbell Island) Airport",ZEM: "Eastmain River Airport",ZER: "Zero Airport",- ZFA: "Faro Airport",+ ZFA: "Faro Airport (ZFA)",ZFD: "Fond-Du-Lac Airport",ZFL: "Zhaosu Tianma Airport",ZFM: "Fort Mcpherson Airport",diff --git a/fli-js/tests/core/airports.test.ts b/fli-js/tests/core/airports.test.tsindex 421601a..313fbff 100644--- a/fli-js/tests/core/airports.test.ts+++ b/fli-js/tests/core/airports.test.ts@@ -4,7 +4,7 @@*/import { describe, expect, test } from "bun:test";-import { searchAirports } from "../../src/core/airports.ts";+import { airportDisplayName, searchAirports } from "../../src/core/airports.ts";describe("searchAirports", () => {test("exact IATA wins with score 100", () => {@@ -75,3 +75,22 @@ describe("searchAirports", () => {expect(jfkCount).toBe(1);});});++describe("disambiguated airport names stay internal", () => {+ test("airportDisplayName strips only the airport's own code suffix", () => {+ expect(airportDisplayName("OKA")).toBe("Naha Airport");+ expect(airportDisplayName("NAH")).toBe("Naha Airport");+ expect(airportDisplayName("JFK")).toBe("John F Kennedy International Airport");+ });++ test("name search returns the plain name under each code", () => {+ const byCode = new Map(searchAirports("Naha Airport", 10).map((m) => [m.code, m.name]));+ expect(byCode.get("OKA")).toBe("Naha Airport");+ expect(byCode.get("NAH")).toBe("Naha Airport");+ });++ test("the hidden suffix never produces a name match", () => {+ const nameMatches = searchAirports("(NC", 10).filter((m) => m.match_type === "name");+ expect(nameMatches).toEqual([]);+ });+});diff --git a/fli-js/tests/models/enums.test.ts b/fli-js/tests/models/enums.test.tsindex 874540d..8601a99 100644--- a/fli-js/tests/models/enums.test.ts+++ b/fli-js/tests/models/enums.test.ts@@ -29,6 +29,24 @@ describe("Airport enum", () => {test("enum covers >7000 codes", () => {expect(Object.keys(AIRPORT_NAMES).length).toBeGreaterThan(7000);});+ test("display names are disambiguated to match the Python package", () => {+ // data/airports.csv gives OKA (Okinawa, Japan) and NAH (Naha,+ // Indonesia) the same raw name ("Naha Airport"). The Python Airport+ // enum disambiguates duplicate names by appending " (CODE)" so every+ // Enum member stays distinct; AIRPORT_NAMES must carry the same+ // suffixed names so the two packages' display output matches.+ expect(AIRPORT_NAMES.OKA).toBe("Naha Airport (OKA)");+ expect(AIRPORT_NAMES.NAH).toBe("Naha Airport (NAH)");+ expect(AIRPORT_NAMES.OKA).not.toBe(AIRPORT_NAMES.NAH);++ expect(AIRPORT_NAMES.TRI).toBe("Tri-Cities Airport (TRI)");+ expect(AIRPORT_NAMES.PSC).toBe("Tri-Cities Airport (PSC)");+ expect(AIRPORT_NAMES.TRI).not.toBe(AIRPORT_NAMES.PSC);++ expect(AIRPORT_NAMES.NTL).toBe("Newcastle Airport (NTL)");+ expect(AIRPORT_NAMES.NCL).toBe("Newcastle Airport (NCL)");+ expect(AIRPORT_NAMES.NTL).not.toBe(AIRPORT_NAMES.NCL);+ });});describe("Airline enum", () => {diff --git a/fli/cli/utils.py b/fli/cli/utils.pyindex 3aac440..db0ea50 100644--- a/fli/cli/utils.py+++ b/fli/cli/utils.py@@ -19,7 +19,7 @@ from fli.core.builders import normalize_datefrom fli.core.parsers import ParseErrorfrom fli.core.parsers import parse_airlines as core_parse_airlinesfrom fli.core.parsers import parse_max_stops as core_parse_max_stops-from fli.models import Airline, Airport, MaxStops, TripType+from fli.models import Airline, Airport, MaxStops, TripType, display_namedef validate_currency(@@ -161,8 +161,8 @@ def filter_dates_by_days(dates: list, days: list[DayOfWeek], trip_type: TripTypedef format_airport(airport: Airport) -> str:- """Format airport code and name (first two words)."""- name_parts = airport.value.split()[:3] # Get first three words+ """Format airport code and name (first three words)."""+ name_parts = display_name(airport).split()[:3] # Get first three wordsname = " ".join(name_parts)return f"{airport.name} ({name})"@@ -176,12 +176,12 @@ def format_duration(minutes: int) -> str:def serialize_airport(airport: Airport) -> dict[str, str]:"""Serialize an airport for machine-readable output."""- return {"code": airport.name, "name": airport.value}+ return {"code": airport.name, "name": display_name(airport)}def serialize_airline(airline: Airline) -> dict[str, str]:"""Serialize an airline for machine-readable output."""- return {"code": airline.name.removeprefix("_"), "name": airline.value}+ return {"code": airline.name.removeprefix("_"), "name": display_name(airline)}def serialize_flight_leg(leg: Any) -> dict[str, Any]:diff --git a/fli/core/airports.py b/fli/core/airports.pyindex 74d7ba5..e2db32f 100644--- a/fli/core/airports.py+++ b/fli/core/airports.py@@ -4,7 +4,7 @@ from typing import Literalfrom pydantic import BaseModel, ConfigDict, Field-from fli.models import Airport+from fli.models import Airport, display_namefrom fli.models.airport import AIRPORT_NAMES# Curated mapping of city names and common abbreviations to IATA codes.@@ -119,7 +119,9 @@ def search_airports(query: str, limit: int = 10) -> list[AirportMatch]:if query_upper in Airport.__members__:airport = Airport[query_upper]results.append(- AirportMatch(code=airport, name=airport.value, match_type="iata_exact", score=100.0)+ AirportMatch(+ code=airport, name=display_name(airport), match_type="iata_exact", score=100.0+ ))seen_codes.add(query_upper)@@ -129,7 +131,9 @@ def search_airports(query: str, limit: int = 10) -> list[AirportMatch]:if code not in seen_codes:airport = Airport[code]results.append(- AirportMatch(code=airport, name=airport.value, match_type="city", score=90.0)+ AirportMatch(+ code=airport, name=display_name(airport), match_type="city", score=90.0+ ))seen_codes.add(code)@@ -142,7 +146,10 @@ def search_airports(query: str, limit: int = 10) -> list[AirportMatch]:airport = Airport[code]results.append(AirportMatch(- code=airport, name=airport.value, match_type="city", score=80.0+ code=airport,+ name=display_name(airport),+ match_type="city",+ score=80.0,))seen_codes.add(code)@@ -154,27 +161,33 @@ def search_airports(query: str, limit: int = 10) -> list[AirportMatch]:for code, airport_name in AIRPORT_NAMES.items():if code in seen_codes:continue- airport_name_lower = airport_name.lower()+ # Match on the name users see, not the internal " (CODE)" uniqueness suffix.+ airport_name_lower = airport_name.removesuffix(f" ({code})").lower()if query_lower in airport_name_lower:# 0.1-per-position weight keeps name matches (max ~70) below# city matches (80) regardless of where the substring lands.pos = airport_name_lower.find(query_lower)score = 70.0 - (pos * 0.1)results.append(- AirportMatch(code=Airport[code], name=airport_name, match_type="name", score=score)+ AirportMatch(+ code=Airport[code],+ name=display_name(Airport[code]),+ match_type="name",+ score=score,+ ))seen_codes.add(code)# Priority 5: IATA code prefix match (handles "SF" matching "SFO").if len(query_upper) <= 3:- for code, airport_name in AIRPORT_NAMES.items():+ for code in AIRPORT_NAMES:if code in seen_codes:continueif code.startswith(query_upper):results.append(AirportMatch(code=Airport[code],- name=airport_name,+ name=display_name(Airport[code]),match_type="iata_prefix",score=60.0,)diff --git a/fli/models/__init__.py b/fli/models/__init__.pyindex 89acec1..6e4af71 100644--- a/fli/models/__init__.py+++ b/fli/models/__init__.py@@ -22,8 +22,10 @@ from .google_flights import (TimeRestrictions,TripType,)+from .names import display_name__all__ = [+ "display_name","Airline","Airport","Alliance",diff --git a/fli/models/airline.py b/fli/models/airline.pyindex 4a94df3..41f102a 100644--- a/fli/models/airline.py+++ b/fli/models/airline.py@@ -140,7 +140,7 @@ AIRLINE_NAMES: dict[str, str] = {"DH": "Douniah Airlines","DI": "Norwegian Air UK","DJ": "AirAsia Japan",- "DK": "Thomas Cook Airlines",+ "DK": "Thomas Cook Airlines (DK)","DL": "Delta Air Lines","DM": "Arajet","DN": "Norwegian Air Argentina",@@ -446,14 +446,14 @@ AIRLINE_NAMES: dict[str, str] = {"MQ": "Envoy Air","MR": "Hunnu Air","MS": "EgyptAir",- "MT": "Thomas Cook Airlines",+ "MT": "Thomas Cook Airlines (MT)","MU": "China Eastern Airlines","MV": "Air Mediterranean","MW": "Mokulele Airlines","MX": "Breeze Airways","MY": "MASwings","MZ": "Amakusa Airlines",- "N0": "Norse Atlantic Airways",+ "N0": "Norse Atlantic Airways (N0)","N2": "Dagestan Airlines","N3": "Aerolineas Mas","N4": "Nord Wind",@@ -522,7 +522,7 @@ AIRLINE_NAMES: dict[str, str] = {"P1": "Publiccharters Com","P2": "Airkenya Express","P3": "CargoLogicAir",- "P4": "Aerolineas Sosa",+ "P4": "Aerolineas Sosa (P4)","P5": "Copa Airlines Colombia","P6": "Pascan Aviation","P8": "SprintAir",@@ -621,7 +621,7 @@ AIRLINE_NAMES: dict[str, str] = {"RX": "Regent Airways","RY": "Jiangxi Air","RZ": "SANSA Airlines",- "S0": "Aerolineas Sosa",+ "S0": "Aerolineas Sosa (S0)","S1": "Lufthansa Systems","S2": "Jet Lite","S3": "SBA Airlines",@@ -765,10 +765,10 @@ AIRLINE_NAMES: dict[str, str] = {"W3": "Arik Air","W4": "LC Péru","W5": "Mahan Airlines",- "W6": "Wizz Air",+ "W6": "Wizz Air (W6)","W7": "Sayakhat Airlines","W8": "Caribbean Winds Airlines",- "W9": "Wizz Air",+ "W9": "Wizz Air (W9)","WA": "KLM Cityhopper","WB": "Rwandair","WC": "Islena Airlines",@@ -799,7 +799,7 @@ AIRLINE_NAMES: dict[str, str] = {"X3": "TUIfly","X4": "Air Excursions","X6": "Airlines Reporting Corp",- "X7": "Challenge Aero",+ "X7": "Challenge Aero (X7)","X9": "Avion Express","XB": "IATA","XC": "Corendon Airlines",@@ -857,7 +857,7 @@ AIRLINE_NAMES: dict[str, str] = {"YW": "Air Nostrum","YX": "Republic Airline","YZ": "Alas Uruguay",- "Z0": "Norse Atlantic Airways",+ "Z0": "Norse Atlantic Airways (Z0)","Z2": "AirAsia Zest","Z3": "PM Air","Z4": "Zagrosjet",@@ -916,11 +916,11 @@ AIRLINE_NAMES: dict[str, str] = {"_1P": "Travelport Worldspan","_1Q": "Joint Stock Company Ital","_1R": "Bird Information Systems",- "_1S": "Sabre",+ "_1S": "Sabre (1S)","_1T": "East Line","_1U": "ITA Software","_1V": "Galileo International",- "_1W": "Sabre",+ "_1W": "Sabre (1W)","_1X": "Branson Air Express","_1Y": "Electronic Data Systems (EDS)","_1Z": "Fantasia Info Network",@@ -1000,7 +1000,7 @@ AIRLINE_NAMES: dict[str, str] = {"_4Y": "Discover Airlines","_4Z": "Airlink","_5B": "Bassaka Air",- "_5C": "Challenge Aero",+ "_5C": "Challenge Aero (5C)","_5D": "Aeroméxico Connect","_5E": "Aero","_5F": "Fly One",diff --git a/fli/models/airport.py b/fli/models/airport.pyindex 513d8ab..78b6561 100644--- a/fli/models/airport.py+++ b/fli/models/airport.py@@ -172,7 +172,7 @@ AIRPORT_NAMES: dict[str, str] = {"AHU": "Cherif Al Idrissi Airport","AHZ": "L'alpe D'huez Airport","AIA": "Alliance Municipal Airport",- "AID": "Anderson Regional Airport",+ "AID": "Anderson Regional Airport (AID)","AIE": "Aiome Airport","AIF": "Marcelo Pires Halzhausen Airport","AIG": "Yalinga Airport",@@ -195,7 +195,7 @@ AIRPORT_NAMES: dict[str, str] = {"AJL": "Lengpui Airport","AJN": "Ouani Airport","AJR": "Arvidsjaur Airport",- "AJU": "Santa Maria Airport",+ "AJU": "Santa Maria Airport (AJU)","AJY": "Mano Dayak International Airport","AKA": "Ankang Airport","AKB": "Atka Airport",@@ -262,7 +262,7 @@ AIRPORT_NAMES: dict[str, str] = {"AMZ": "Ardmore Airport","ANB": "Anniston Regional Airport","ANC": "Ted Stevens Anchorage International Airport",- "AND": "Anderson Regional Airport",+ "AND": "Anderson Regional Airport (AND)","ANE": "Angers-Loire Airport","ANF": "Cerro Moreno Airport","ANG": "Angouleme-Brie-Champniers Airport",@@ -647,7 +647,7 @@ AIRPORT_NAMES: dict[str, str] = {"BHP": "Bhojpur Airport","BHQ": "Broken Hill Airport","BHR": "Bharatpur Airport",- "BHS": "Bathurst Airport",+ "BHS": "Bathurst Airport (BHS)","BHU": "Bhavnagar Airport","BHV": "Bahawalpur Airport","BHW": "Bhagatanwala Airport",@@ -829,7 +829,7 @@ AIRPORT_NAMES: dict[str, str] = {"BQL": "Boulia Airport","BQN": "Rafael Hernandez Airport","BQO": "Bouna Airport",- "BQQ": "Barra Airport",+ "BQQ": "Barra Airport (BQQ)","BQS": "Ignatyevo Airport","BQT": "Brest Airport","BQU": "J F Mitchell Airport",@@ -846,7 +846,7 @@ AIRPORT_NAMES: dict[str, str] = {"BRN": "Bern Belp Airport","BRO": "Brownsville/South Padre Island International Airport","BRQ": "Brno-Turany Airport",- "BRR": "Barra Airport",+ "BRR": "Barra Airport (BRR)","BRS": "Bristol International Airport","BRT": "Bathurst Island Airport","BRU": "Brussels Airport",@@ -855,14 +855,14 @@ AIRPORT_NAMES: dict[str, str] = {"BRY": "Samuels Field","BSA": "Bosaso Airport","BSB": "Presidente Juscelino Kubistschek International Airport",- "BSC": "Jose Celestino Mutis Airport",+ "BSC": "Jose Celestino Mutis Airport (BSC)","BSD": "Baoshan Yunduan Airport","BSE": "Sematan Airport","BSF": "Bradshaw Army Airfield","BSG": "Bata Airport","BSJ": "Bairnsdale Airport","BSK": "Biskra Airport",- "BSL": "EuroAirport Basel-Mulhouse-Freiburg Airport",+ "BSL": "EuroAirport Basel-Mulhouse-Freiburg Airport (BSL)","BSM": "Bishe Kola Air Base","BSN": "Bossangoa Airport","BSO": "Basco Airport",@@ -957,7 +957,7 @@ AIRPORT_NAMES: dict[str, str] = {"BWQ": "Brewarrina Airport","BWT": "Wynyard Airport","BWU": "Sydney Bankstown Airport",- "BWW": "Las Brujas Airport",+ "BWW": "Las Brujas Airport (BWW)","BXA": "George R Carr Memorial Air Field","BXB": "Babo Airport","BXD": "Bade Airport",@@ -994,7 +994,7 @@ AIRPORT_NAMES: dict[str, str] = {"BYT": "Bantry Aerodrome","BYU": "Bayreuth Airport","BYW": "Blakely Island Airport",- "BZA": "San Pedro Airport",+ "BZA": "San Pedro Airport (BZA)","BZC": "Umberto Modiano Airport","BZD": "Balranald Airport","BZE": "Philip S. W. Goldson International Airport",@@ -1259,7 +1259,7 @@ AIRPORT_NAMES: dict[str, str] = {"CLR": "Cliff Hatfield Memorial Airport","CLS": "Chehalis-Centralia Airport","CLT": "Charlotte/Douglas International Airport",- "CLU": "Columbus Municipal Airport",+ "CLU": "Columbus Municipal Airport (CLU)","CLV": "Caldas Novas Airport","CLW": "Clearwater Executive Airport","CLX": "Clorinda Airport",@@ -1363,7 +1363,7 @@ AIRPORT_NAMES: dict[str, str] = {"CQW": "Wulong Chongqing Xiannvshan Airport","CRA": "Craiova Airport","CRB": "Collarenebri Airport",- "CRC": "Santa Ana Airport",+ "CRC": "Santa Ana Airport (CRC)","CRD": "General E. Mosconi Airport","CRE": "Grand Strand Airport","CRF": "Carnot Airport",@@ -1440,7 +1440,7 @@ AIRPORT_NAMES: dict[str, str] = {"CUP": "General Francisco Bermudez Airport","CUQ": "Coen Airport","CUR": "Hato International Airport",- "CUS": "Columbus Municipal Airport",+ "CUS": "Columbus Municipal Airport (CUS)","CUT": "Cutral-Co Airport","CUU": "General Roberto Fierro Villalobos International Airport","CUV": "Casigua El Cubo Airport",@@ -1512,7 +1512,7 @@ AIRPORT_NAMES: dict[str, str] = {"CZO": "Chistochina Airport","CZS": "Cruzeiro do Sul Airport","CZT": "Dimmit County Airport",- "CZU": "Las Brujas Airport",+ "CZU": "Las Brujas Airport (CZU)","CZX": "Changzhou Airport","CZY": "Cluny Airport","DAA": "Davison Army Air Field",@@ -1520,7 +1520,7 @@ AIRPORT_NAMES: dict[str, str] = {"DAC": "Dhaka / Hazrat Shahjalal International Airport","DAD": "Da Nang International Airport","DAG": "Barstow-Daggett Airport",- "DAK": "Dakhla Airport",+ "DAK": "Dakhla Airport (DAK)","DAL": "Dallas Love Field","DAM": "Damascus International Airport","DAN": "Danville Regional Airport",@@ -1865,7 +1865,7 @@ AIRPORT_NAMES: dict[str, str] = {"ELL": "Ellisras Matimba Airport","ELM": "Elmira/Corning Regional Airport","ELN": "Bowers Field",- "ELO": "El Dorado Airport",+ "ELO": "El Dorado Airport (ELO)","ELP": "El Paso International Airport","ELQ": "Gassim Airport","ELS": "Ben Schoeman Airport",@@ -1904,7 +1904,7 @@ AIRPORT_NAMES: dict[str, str] = {"EOH": "Enrique Olaya Herrera Airport","EOI": "Eday Airport","EOK": "Keokuk Municipal Airport",- "EOR": "El Dorado Airport",+ "EOR": "El Dorado Airport (EOR)","EOS": "Neosho Hugh Robinson Airport","EOZ": "Elorza Airport","EPA": "El Palomar Airport",@@ -1958,7 +1958,7 @@ AIRPORT_NAMES: dict[str, str] = {"ETZ": "Metz-Nancy-Lorraine Airport","EUA": "Kaufana Airport","EUC": "Eucla Airport",- "EUE": "Eureka Airport",+ "EUE": "Eureka Airport (EUE)","EUF": "Weedon Field","EUG": "Mahlon Sweet Field","EUM": "Neumunster Airport",@@ -1999,7 +1999,7 @@ AIRPORT_NAMES: dict[str, str] = {"FAH": "Farah Airport","FAI": "Fairbanks International Airport","FAM": "Farmington Regional Airport",- "FAO": "Faro Airport",+ "FAO": "Faro Airport (FAO)","FAQ": "Frieda River Airport","FAR": "Hector International Airport","FAT": "Fresno Yosemite International Airport",@@ -2028,7 +2028,7 @@ AIRPORT_NAMES: dict[str, str] = {"FDF": "Martinique Aime Cesaire International Airport","FDH": "Friedrichshafen Airport","FDK": "Frederick Municipal Airport",- "FDO": "San Fernando Airport",+ "FDO": "San Fernando Airport (FDO)","FDR": "Frederick Regional Airport","FDU": "Bandundu Airport","FDY": "Findlay Airport",@@ -2047,7 +2047,7 @@ AIRPORT_NAMES: dict[str, str] = {"FFL": "Fairfield Municipal Airport","FFM": "Fergus Falls Regional Airport","FFO": "Wright-Patterson Afb Airport",- "FFT": "Capital City Airport",+ "FFT": "Capital City Airport (FFT)","FFU": "Futaleufu Airport","FGD": "Fderik Airport","FGI": "Fagali'i Airport",@@ -2426,7 +2426,7 @@ AIRPORT_NAMES: dict[str, str] = {"GSE": "Gothenburg City Airport","GSH": "Goshen Municipal Airport","GSI": "Grand-Santi Airport",- "GSJ": "San Jose Airport",+ "GSJ": "San Jose Airport (GSJ)","GSM": "Dayrestan Airport","GSN": "Mount Gunson Airport","GSO": "Piedmont Triad International Airport",@@ -2496,7 +2496,7 @@ AIRPORT_NAMES: dict[str, str] = {"GXY": "Greeley-Weld County Airport","GYA": "Capitan de Av. Emilio Beltran Airport","GYD": "Heydar Aliyev International Airport",- "GYE": "Simon Bolivar International Airport",+ "GYE": "Simon Bolivar International Airport (GYE)","GYG": "Magan Airport","GYI": "Gisenyi Airport","GYL": "Argyle Airport",@@ -2526,7 +2526,7 @@ AIRPORT_NAMES: dict[str, str] = {"HAN": "Noi Bai International Airport","HAO": "Butler County Regional/Hogan Field","HAQ": "Hanimaadhoo International Airport",- "HAR": "Capital City Airport",+ "HAR": "Capital City Airport (HAR)","HAS": "Hail Airport","HAT": "Heathlands Airport","HAU": "Haugesund Airport",@@ -2588,7 +2588,7 @@ AIRPORT_NAMES: dict[str, str] = {"HGH": "Hangzhou Xiaoshan International Airport","HGI": "Donyi Polo Airport","HGL": "Helgoland-Dune Airport",- "HGN": "Mae Hong Son Airport",+ "HGN": "Mae Hong Son Airport (HGN)","HGO": "Korhogo Airport","HGR": "Hagerstown Regional/Richard A Henson Field","HGS": "Hastings Airport",@@ -3048,7 +3048,7 @@ AIRPORT_NAMES: dict[str, str] = {"JBK": "Qitai Jiangbulake Airport","JBQ": "La Isabela International Airport","JBR": "Jonesboro Municipal Airport",- "JCB": "Santa Terezinha Airport",+ "JCB": "Santa Terezinha Airport (JCB)","JCI": "New Century Aircenter Airport","JCK": "Julia Creek Airport","JCL": "Ceske Budejovice Airport",@@ -3691,7 +3691,7 @@ AIRPORT_NAMES: dict[str, str] = {"LGL": "Long Lellang Airport","LGO": "Langeoog Airport","LGQ": "Nueva Loja Airport",- "LGR": "Cochrane Airport",+ "LGR": "Cochrane Airport (LGR)","LGS": "Comodoro D.R. Salomon Airport","LGT": "La Gaviota Airport","LGU": "Logan-Cache Airport",@@ -3744,13 +3744,13 @@ AIRPORT_NAMES: dict[str, str] = {"LKN": "Leknes Airport","LKO": "Chaudhary Charan Singh International Airport","LKP": "Lake Placid Airport",- "LKV": "Lake County Airport",+ "LKV": "Lake County Airport (LKV)","LKW": "Lekhwair Airport","LKY": "Lake Manyara Airport","LKZ": "RAF Lakenheath","LLA": "Lulea Airport","LLB": "Qiannan Libo Airport",- "LLE": "Riverside Airport",+ "LLE": "Riverside Airport (LLE)","LLF": "Lingling Airport","LLG": "Chillagoe Airport","LLI": "Lalibella Airport",@@ -3795,7 +3795,7 @@ AIRPORT_NAMES: dict[str, str] = {"LNY": "Lanai Airport","LNZ": "Linz Airport","LOA": "Lorraine Airport",- "LOB": "San Rafael Airport",+ "LOB": "San Rafael Airport (LOB)","LOC": "Lock Airport","LOD": "Longana Airport","LOE": "Loei Airport",@@ -3852,7 +3852,7 @@ AIRPORT_NAMES: dict[str, str] = {"LRV": "Gran Roque Airport","LSA": "Losuia Airport","LSB": "Lordsburg Municipal Airport",- "LSC": "La Florida Airport",+ "LSC": "La Florida Airport (LSC)","LSE": "La Crosse Regional Airport","LSF": "Lawson Army Air Field (Fort Benning) Airport","LSG": "Leshan Airport (under construction, unknown coordinates)",@@ -3944,7 +3944,7 @@ AIRPORT_NAMES: dict[str, str] = {"LXR": "Luxor International Airport","LXS": "Limnos Airport","LXU": "Lukulu Airport",- "LXV": "Lake County Airport",+ "LXV": "Lake County Airport (LXV)","LYA": "Luoyang Airport","LYB": "Edward Bodden Airfield","LYC": "Lycksele Airport",@@ -4054,7 +4054,7 @@ AIRPORT_NAMES: dict[str, str] = {"MDQ": "Astor Piazzola International Airport","MDS": "Middle Caicos Airport","MDT": "Harrisburg International Airport",- "MDU": "Mendi Airport",+ "MDU": "Mendi Airport (MDU)","MDW": "Chicago Midway International Airport","MDX": "Mercedes Airport","MDY": "Henderson Field",@@ -4214,7 +4214,7 @@ AIRPORT_NAMES: dict[str, str] = {"MLE": "Velana International Airport","MLF": "Milford Municipal/Ben And Judy Briscoe Field","MLG": "Abdul Rachman Saleh Airport",- "MLH": "EuroAirport Basel-Mulhouse-Freiburg Airport",+ "MLH": "EuroAirport Basel-Mulhouse-Freiburg Airport (MLH)","MLI": "Quad Cities International Airport","MLJ": "Baldwin County Regional Airport","MLK": "Malta Airport",@@ -4290,7 +4290,7 @@ AIRPORT_NAMES: dict[str, str] = {"MOM": "Letfotar Airport","MON": "Mount Cook Airport","MOO": "Moomba Airport",- "MOP": "Mount Pleasant Municipal Airport",+ "MOP": "Mount Pleasant Municipal Airport (MOP)","MOQ": "Morondava Airport","MOR": "Moore-Murrell Airport","MOS": "Moses Point Airport",@@ -4314,7 +4314,7 @@ AIRPORT_NAMES: dict[str, str] = {"MPV": "Edward F Knapp State Airport","MPW": "Mariupol International Airport","MPY": "Maripasoula Airport",- "MPZ": "Mount Pleasant Municipal Airport",+ "MPZ": "Mount Pleasant Municipal Airport (MPZ)","MQA": "Mandora Airport","MQB": "Macomb Municipal Airport","MQC": "Miquelon Airport",@@ -4331,7 +4331,7 @@ AIRPORT_NAMES: dict[str, str] = {"MQQ": "Moundou Airport","MQS": "Mustique Airport","MQT": "Marquette/Sawyer Regional Airport",- "MQU": "Jose Celestino Mutis Airport",+ "MQU": "Jose Celestino Mutis Airport (MQU)","MQW": "Telfair-Wheeler Airport","MQX": "Mekele Airport","MQY": "Smyrna Airport",@@ -4538,7 +4538,7 @@ AIRPORT_NAMES: dict[str, str] = {"NAC": "Naracoorte Airport","NAE": "Natitingou Airport","NAG": "Dr. Babasaheb Ambedkar International Airport",- "NAH": "Naha Airport",+ "NAH": "Naha Airport (NAH)","NAI": "Annai Airport","NAJ": "Nakhchivan Airport","NAK": "Nakhon Ratchasima Airport",@@ -4571,11 +4571,11 @@ AIRPORT_NAMES: dict[str, str] = {"NCH": "Nachingwea Airport","NCI": "Necocli Airport","NCJ": "Sunchales Aeroclub Airport",- "NCL": "Newcastle Airport",+ "NCL": "Newcastle Airport (NCL)","NCN": "Chenega Bay Airport","NCO": "Quonset State Airport","NCR": "San Carlos",- "NCS": "Newcastle Airport",+ "NCS": "Newcastle Airport (NCS)","NCT": "Guanacaste Airport","NCU": "Nukus Airport","NCY": "Annecy-Haute-Savoie-Mont Blanc Airport",@@ -4587,7 +4587,7 @@ AIRPORT_NAMES: dict[str, str] = {"NDG": "Qiqihar Sanjiazi Airport","NDJ": "N'Djamena International Airport","NDL": "N'Dele Airport",- "NDM": "Mendi Airport",+ "NDM": "Mendi Airport (NDM)","NDR": "Nador International Airport","NDS": "Sandstone Airport","NDU": "Rundu Airport",@@ -4678,7 +4678,7 @@ AIRPORT_NAMES: dict[str, str] = {"NMR": "Nappa Merrie Airport","NMS": "Namsang Airport","NNA": "Kenitra Airport",- "NNB": "Santa Ana Airport",+ "NNB": "Santa Ana Airport (NNB)","NNG": "Nanning Wuxu Airport","NNI": "Namutoni Airport","NNK": "Naknek Airport",@@ -4693,7 +4693,7 @@ AIRPORT_NAMES: dict[str, str] = {"NOB": "Nosara Airport","NOC": "Ireland West Knock Airport","NOD": "Norden-Norddeich Airport",- "NOG": "Nogales International Airport",+ "NOG": "Nogales International Airport (NOG)","NOJ": "Noyabrsk Airport","NOK": "Xavantina Airport","NON": "Nonouti Airport",@@ -4751,7 +4751,7 @@ AIRPORT_NAMES: dict[str, str] = {"NTG": "Nantong Airport","NTI": "Stenkol Airport","NTJ": "Sanpete County Regional Airport",- "NTL": "Newcastle Airport",+ "NTL": "Newcastle Airport (NTL)","NTN": "Normanton Airport","NTO": "Agostinho Neto Airport","NTQ": "Noto Airport",@@ -4890,7 +4890,7 @@ AIRPORT_NAMES: dict[str, str] = {"OIR": "Okushiri Airport","OIT": "Oita Airport","OJC": "Johnson County Executive Airport",- "OKA": "Naha Airport",+ "OKA": "Naha Airport (OKA)","OKC": "Okc Will Rogers International Airport","OKD": "Okadama Airport","OKE": "Okierabu Airport",@@ -4923,8 +4923,8 @@ AIRPORT_NAMES: dict[str, str] = {"OLN": "Lago Musters Airport","OLO": "Olomouc Glider Airport","OLP": "Olympic Dam Airport",- "OLS": "Nogales International Airport",- "OLU": "Columbus Municipal Airport",+ "OLS": "Nogales International Airport (OLS)",+ "OLU": "Columbus Municipal Airport (OLU)","OLV": "Olive Branch/Taylor Field","OLY": "Olney-Noble Airport","OLZ": "Olyokminsk Airport",@@ -5175,7 +5175,7 @@ AIRPORT_NAMES: dict[str, str] = {"PFQ": "Parsabade Moghan Airport","PFR": "Ilebo Airport","PGA": "Page Municipal Airport",- "PGC": "Grant County Airport",+ "PGC": "Grant County Airport (PGC)","PGD": "Punta Gorda Airport","PGF": "Perpignan-Rivesaltes (Llabanere) Airport","PGH": "Pantnagar Airport",@@ -5271,9 +5271,9 @@ AIRPORT_NAMES: dict[str, str] = {"PLV": "Poltava International Airport","PLW": "Mutiara Airport","PLX": "Semey International Airport",- "PLY": "Plymouth Municipal Airport",+ "PLY": "Plymouth Municipal Airport (PLY)","PLZ": "Port Elizabeth Airport",- "PMA": "Pemba Airport",+ "PMA": "Pemba Airport (PMA)","PMB": "Pembina Municipal Airport","PMC": "El Tepual Airport","PMD": "Palmdale Usaf Plant 42 Airport",@@ -5320,7 +5320,7 @@ AIRPORT_NAMES: dict[str, str] = {"POH": "Pocahontas Municipal Airport","POI": "Capitan Nicolas Rojas Airport","POJ": "Patos de Minas Airport",- "POL": "Pemba Airport",+ "POL": "Pemba Airport (POL)","POM": "Port Moresby Jacksons International Airport","PON": "Poptun Airport","POO": "Pocos de Caldas Airport",@@ -5383,7 +5383,7 @@ AIRPORT_NAMES: dict[str, str] = {"PRZ": "Prineville Airport","PSA": "Pisa / San Giusto - Galileo Galilei International Airport","PSB": "Mid-State Airport",- "PSC": "Tri-Cities Airport",+ "PSC": "Tri-Cities Airport (PSC)","PSD": "Port Said Airport","PSE": "Mercedita Airport","PSF": "Pittsfield Municipal Airport",@@ -5480,11 +5480,11 @@ AIRPORT_NAMES: dict[str, str] = {"PYH": "Cacique Aramare Airport","PYJ": "Polyarny Airport","PYK": "Payam Airport",- "PYM": "Plymouth Municipal Airport",+ "PYM": "Plymouth Municipal Airport (PYM)","PYO": "Putumayo Airport","PYR": "Andravida Airport","PYS": "Paradise Skypark Airport",- "PYY": "Mae Hong Son Airport",+ "PYY": "Mae Hong Son Airport (PYY)","PYZ": "Pias Airport","PZA": "Paz De Ariporo Airport","PZB": "Pietermaritzburg Airport",@@ -5568,7 +5568,7 @@ AIRPORT_NAMES: dict[str, str] = {"RAH": "Rafha Domestic Airport","RAI": "Praia International Airport","RAK": "Menara Airport",- "RAL": "Riverside Airport",+ "RAL": "Riverside Airport (RAL)","RAM": "Ramingining Airport","RAN": "Ravenna Airport","RAO": "Leite Lopes Airport",@@ -5671,7 +5671,7 @@ AIRPORT_NAMES: dict[str, str] = {"RHP": "Ramechhap Airport","RHT": "Alxa Right Banner Badanjilin Airport","RHV": "Reid-Hillview Of Santa Clara County Airport",- "RIA": "Santa Maria Airport",+ "RIA": "Santa Maria Airport (RIA)","RIB": "Capitan Av. Selin Zeitun Lopez Airport","RIC": "Richmond International Airport","RID": "Richmond Municipal Airport",@@ -5780,7 +5780,7 @@ AIRPORT_NAMES: dict[str, str] = {"RRR": "Raroia Airport","RRS": "Røros Airport","RRT": "Warroad International Memorial Airport",- "RSA": "Santa Rosa Airport",+ "RSA": "Santa Rosa Airport (RSA)","RSB": "Roseberth Airport","RSD": "Rock Sound Airport","RSH": "Russian Mission Airport",@@ -5841,7 +5841,7 @@ AIRPORT_NAMES: dict[str, str] = {"RYK": "Shaikh Zaid Airport","RYN": "Royan-Medis Airport","RYO": "28 De Noviembre Airport",- "RZA": "Santa Cruz Airport",+ "RZA": "Santa Cruz Airport (RZA)","RZE": "Rzeszow-Jasionka Airport","RZN": "Turlatovo Airport","RZP": "Cesar Lim Rodriguez Airport",@@ -5951,7 +5951,7 @@ AIRPORT_NAMES: dict[str, str] = {"SFB": "Orlando Sanford International Airport","SFC": "St-Francois Airport","SFD": "San Fernando De Apure Airport",- "SFE": "San Fernando Airport",+ "SFE": "San Fernando Airport (SFE)","SFF": "Felts Field","SFG": "L'Esperance Airport","SFH": "San Felipe International Airport",@@ -5975,7 +5975,7 @@ AIRPORT_NAMES: dict[str, str] = {"SGI": "Mushaf Air Base","SGL": "Sangley Point Air Base","SGN": "Tan Son Nhat International Airport",- "SGO": "St George Airport",+ "SGO": "St George Airport (SGO)","SGP": "Shay Gap Airport","SGQ": "Sanggata Airport","SGR": "Sugar Land Regional Airport",@@ -6000,7 +6000,7 @@ AIRPORT_NAMES: dict[str, str] = {"SHM": "Nanki Shirahama Airport","SHN": "Sanderson Field","SHO": "King Mswati III Intl",- "SHQ": "Southport Airport",+ "SHQ": "Southport Airport (SHQ)","SHR": "Sheridan County Airport","SHS": "Shashi Airport","SHT": "Shepparton Airport",@@ -6038,7 +6038,7 @@ AIRPORT_NAMES: dict[str, str] = {"SJC": "Norman Y Mineta San Jose International Airport","SJD": "Los Cabos International Airport","SJE": "Jorge E. Gonzalez Torres Airport",- "SJI": "San Jose Airport",+ "SJI": "San Jose Airport (SJI)","SJJ": "Sarajevo International Airport","SJK": "Professor Urbano Ernesto Stumpf Airport","SJL": "Sao Gabriel da Cachoeira Airport",@@ -6079,7 +6079,7 @@ AIRPORT_NAMES: dict[str, str] = {"SLD": "Sliac Airport","SLE": "Mcnary Field","SLF": "Sulayel Airport",- "SLG": "Smith Field",+ "SLG": "Smith Field (SLG)","SLH": "Sola Airport","SLI": "Solwesi Airport","SLJ": "Solomon Airport",@@ -6098,12 +6098,12 @@ AIRPORT_NAMES: dict[str, str] = {"SLX": "Salt Cay Airport","SLY": "Salekhard Airport","SLZ": "Marechal Cunha Machado International Airport",- "SMA": "Santa Maria Airport",+ "SMA": "Santa Maria Airport (SMA)","SMB": "Franco Bianco Airport",- "SMD": "Smith Field",+ "SMD": "Smith Field (SMD)","SME": "Lake Cumberland Regional Airport","SMF": "Sacramento International Airport",- "SMG": "Santa Maria Airport",+ "SMG": "Santa Maria Airport (SMG)","SMI": "Samos Airport","SMK": "St Michael Airport","SML": "Stella Maris Airport",@@ -6111,7 +6111,7 @@ AIRPORT_NAMES: dict[str, str] = {"SMN": "Lemhi County Airport","SMO": "Santa Monica Municipal Airport","SMQ": "Sampit(Hasan) Airport",- "SMR": "Simon Bolivar International Airport",+ "SMR": "Simon Bolivar International Airport (SMR)","SMS": "Sainte Marie Airport","SMU": "Sheep Mountain Airport","SMV": "Samedan Airport",@@ -6141,7 +6141,7 @@ AIRPORT_NAMES: dict[str, str] = {"SNW": "Thandwe Airport","SNX": "Semnan Airport","SNY": "Sidney Municipal/Lloyd W Carr Field",- "SNZ": "Santa Cruz Airport",+ "SNZ": "Santa Cruz Airport (SNZ)","SOB": "Sarmellek International Airport","SOC": "Adi Sumarmo Wiryokusumo Airport","SOD": "Sorocaba Airport",@@ -6178,7 +6178,7 @@ AIRPORT_NAMES: dict[str, str] = {"SPU": "Split Airport","SPW": "Spencer Municipal Airport","SPX": "Sphinx International Airport",- "SPY": "San Pedro Airport",+ "SPY": "San Pedro Airport (SPY)","SPZ": "Springdale Municipal Airport","SQA": "Santa Ynez/Kunkle Field","SQC": "Southern Cross Airport",@@ -6198,12 +6198,12 @@ AIRPORT_NAMES: dict[str, str] = {"SQX": "Sao Miguel do Oeste Airport","SQY": "Sao Lourenco do Sul Airport","SQZ": "RAF Scampton",- "SRA": "Santa Rosa Airport",+ "SRA": "Santa Rosa Airport (SRA)","SRB": "Santa Rosa De Yacuma Airport","SRC": "Searcy Regional Airport","SRD": "San Ramon Airport","SRE": "Alcantarí International Airport",- "SRF": "San Rafael Airport",+ "SRF": "San Rafael Airport (SRF)","SRG": "Achmad Yani Airport","SRH": "Sarh Airport","SRJ": "Capitan Av. German Quiroga G. Airport",@@ -6239,7 +6239,7 @@ AIRPORT_NAMES: dict[str, str] = {"STC": "St Cloud Regional Airport","STD": "Mayor Buenaventura Vivas International Airport","STE": "Stevens Point Municipal Airport",- "STG": "St George Airport",+ "STG": "St George Airport (STG)","STH": "Strathmore Airport","STI": "Cibao International Airport","STJ": "Rosecrans Memorial Airport",@@ -6256,7 +6256,7 @@ AIRPORT_NAMES: dict[str, str] = {"STW": "Stavropol Shpakovskoye Airport","STX": "Henry E Rohlsen Airport","STY": "Nueva Hesperides International Airport",- "STZ": "Santa Terezinha Airport",+ "STZ": "Santa Terezinha Airport (STZ)","SUA": "Witham Field","SUB": "Juanda International Airport","SUD": "Stroud Municipal Airport",@@ -6282,7 +6282,7 @@ AIRPORT_NAMES: dict[str, str] = {"SUY": "Suntar Airport","SVA": "Savoonga Airport","SVB": "Sambava Airport",- "SVC": "Grant County Airport",+ "SVC": "Grant County Airport (SVC)","SVD": "Argyle International Airport","SVE": "Susanville Municipal Airport","SVF": "Save Airport",@@ -6426,7 +6426,7 @@ AIRPORT_NAMES: dict[str, str] = {"TCL": "Tuscaloosa Ntl Airport","TCM": "Mcchord Field (Joint Base Lewis-Mcchord) Airport","TCN": "Tehuacan Airport",- "TCO": "La Florida Airport",+ "TCO": "La Florida Airport (TCO)","TCP": "Taba International Airport","TCQ": "Coronel FAP Carlos Ciriani Santa Rosa International Airport","TCR": "Tuticorin Southwest Airport",@@ -6694,7 +6694,7 @@ AIRPORT_NAMES: dict[str, str] = {"TRF": "Sandefjord Airport Torp","TRG": "Tauranga Airport","TRH": "Trona Airport",- "TRI": "Tri-Cities Airport",+ "TRI": "Tri-Cities Airport (TRI)","TRK": "Juwata Airport","TRL": "Terrell Municipal Airport","TRM": "Jacqueline Cochran Regional Airport",@@ -6774,7 +6774,7 @@ AIRPORT_NAMES: dict[str, str] = {"TWB": "Toowoomba Airport","TWC": "Tumxuk Tangwangcheng Airport","TWD": "Jefferson County International Airport",- "TWE": "Taylor Airport",+ "TWE": "Taylor Airport (TWE)","TWF": "Joslin Field/Magic Valley Regional Airport","TWU": "Tawau Airport","TWZ": "Pukaki Airport",@@ -6797,7 +6797,7 @@ AIRPORT_NAMES: dict[str, str] = {"TYR": "Tyler Pounds Regional Airport","TYS": "Mc Ghee Tyson Airport","TYT": "Treinta y Tres Airport",- "TYZ": "Taylor Airport",+ "TYZ": "Taylor Airport (TYZ)","TZC": "Tuscola Area Airport","TZL": "Tuzla International Airport","TZR": "Taszar Air Base",@@ -6834,7 +6834,7 @@ AIRPORT_NAMES: dict[str, str] = {"UDI": "Ten. Cel. Aviador Cesar Bombonato Airport","UDJ": "Uzhhorod International Airport","UDR": "Maharana Pratap Airport",- "UEE": "Queenstown Airport",+ "UEE": "Queenstown Airport (UEE)","UEL": "Quelimane Airport","UEN": "Urengoy Airport","UEO": "Kumejima Airport",@@ -6951,7 +6951,7 @@ AIRPORT_NAMES: dict[str, str] = {"UTR": "Uttaradit Airport","UTS": "Ust-Tsylma Airport","UTT": "K. D. Matanzima Airport",- "UTW": "Queenstown Airport",+ "UTW": "Queenstown Airport (UTW)","UUA": "Bugulma Airport","UUD": "Ulan-Ude Airport (Mukhino)","UUK": "Ugnu-Kuparuk Airport",@@ -7036,7 +7036,7 @@ AIRPORT_NAMES: dict[str, str] = {"VIH": "Rolla Ntl Airport","VII": "Vinh Airport","VIJ": "Virgin Gorda Airport",- "VIL": "Dakhla Airport",+ "VIL": "Dakhla Airport (VIL)","VIN": "Havryshivka Vinnytsia International Airport","VIP": "Payerne Airport","VIQ": "Viqueque Airport",@@ -7295,12 +7295,12 @@ AIRPORT_NAMES: dict[str, str] = {"WTZ": "Whitianga Airport","WUA": "Wuhai Airport","WUD": "Wudinna Airport",- "WUG": "Wau Airport",+ "WUG": "Wau Airport (WUG)","WUH": "Wuhan Tianhe International Airport","WUI": "Murrin Murrin Airport","WUN": "Wiluna Airport","WUS": "Nanping Wuyishan Airport",- "WUU": "Wau Airport",+ "WUU": "Wau Airport (WUU)","WUX": "Sunan Shuofang International Airport","WUZ": "Wuzhou Xijiang Airport","WVB": "Walvis Bay Airport",@@ -7443,7 +7443,7 @@ AIRPORT_NAMES: dict[str, str] = {"YCK": "Colville Lake Airport","YCL": "Charlo Airport","YCM": "St. Catharines Niagara District Airport",- "YCN": "Cochrane Airport",+ "YCN": "Cochrane Airport (YCN)","YCO": "Kugluktuk Airport","YCQ": "Chetwynd Airport","YCR": "Cross Lake (Charlie Sinclair Memorial) Airport",@@ -7456,7 +7456,7 @@ AIRPORT_NAMES: dict[str, str] = {"YDA": "Dawson City Airport","YDB": "Burwash Airport","YDC": "Drayton Valley Industrial Airport",- "YDF": "Deer Lake Airport",+ "YDF": "Deer Lake Airport (YDF)","YDG": "Digby / Annapolis Regional Airport","YDJ": "Hatchet Lake Airport","YDL": "Dease Lake Airport",@@ -7481,7 +7481,7 @@ AIRPORT_NAMES: dict[str, str] = {"YER": "Fort Severn Airport","YES": "Yasouj Airport","YET": "Edson Airport",- "YEU": "Eureka Airport",+ "YEU": "Eureka Airport (YEU)","YEV": "Inuvik (Mike Zubko) Airport","YEY": "Amos Magny Airport","YFA": "Fort Albany Airport",@@ -7517,7 +7517,7 @@ AIRPORT_NAMES: dict[str, str] = {"YHD": "Dryden Regional Airport","YHE": "Hope Airport","YHF": "Hearst Rene Fontaine Municipal Airport",- "YHG": "Charlottetown Airport",+ "YHG": "Charlottetown Airport (YHG)","YHI": "Ulukhaktok Holman Airport","YHJ": "Nanchang Yaohu Airport","YHK": "Gjoa Haven Airport",@@ -7634,7 +7634,7 @@ AIRPORT_NAMES: dict[str, str] = {"YPC": "Paulatuk (Nora Aliqatchialuk Ruben) Airport","YPD": "Parry Sound Area Municipal Airport","YPE": "Peace River Airport",- "YPG": "Southport Airport",+ "YPG": "Southport Airport (YPG)","YPH": "Inukjuak Airport","YPJ": "Aupaluk Airport","YPK": "Pitt Meadows Airport",@@ -7737,7 +7737,7 @@ AIRPORT_NAMES: dict[str, str] = {"YVR": "Vancouver International Airport","YVT": "Buffalo Narrows Airport","YVV": "Wiarton Airport",- "YVZ": "Deer Lake Airport",+ "YVZ": "Deer Lake Airport (YVZ)","YWA": "Petawawa Airport","YWB": "Kangiqsujuaq (Wakeham Bay) Airport","YWG": "Winnipeg James Armstrong Richardson International Airport",@@ -7770,7 +7770,7 @@ AIRPORT_NAMES: dict[str, str] = {"YYD": "Smithers Airport","YYE": "Fort Nelson Airport","YYF": "Penticton Airport",- "YYG": "Charlottetown Airport",+ "YYG": "Charlottetown Airport (YYG)","YYH": "Taloyoak Airport","YYJ": "Victoria International Airport","YYL": "Lynn Lake Airport",@@ -7809,7 +7809,7 @@ AIRPORT_NAMES: dict[str, str] = {"ZAT": "Zhaotong Airport","ZAZ": "Zaragoza Air Base","ZBE": "Zabreh Ostrava Airport",- "ZBF": "Bathurst Airport",+ "ZBF": "Bathurst Airport (ZBF)","ZBL": "Thangool (Biloela) Airport","ZBM": "Bromont (Roland Desourdy) Airport","ZBO": "Bowen Airport",@@ -7821,7 +7821,7 @@ AIRPORT_NAMES: dict[str, str] = {"ZEL": "Bella Bella (Campbell Island) Airport","ZEM": "Eastmain River Airport","ZER": "Zero Airport",- "ZFA": "Faro Airport",+ "ZFA": "Faro Airport (ZFA)","ZFD": "Fond-Du-Lac Airport","ZFL": "Zhaosu Tianma Airport","ZFM": "Fort Mcpherson Airport",diff --git a/fli/models/names.py b/fli/models/names.pynew file mode 100644index 0000000..60edf9a--- /dev/null+++ b/fli/models/names.py@@ -0,0 +1,24 @@+"""Display helpers for the generated ``Airport`` / ``Airline`` enums."""++from .airline import Airline+from .airport import Airport+++def display_name(member: Airport | Airline) -> str:+ """Return a member's human-readable name as it should be shown to users.++ Enum values must be unique, so names shared by several members are stored+ with a disambiguating `` (CODE)`` suffix (see ``scripts/generate_enums.py``).+ That suffix is an internal detail: the code is always presented separately,+ so it is stripped here.++ Args:+ member: An ``Airport`` or ``Airline`` enum member.++ Returns:+ The name without any `` (CODE)`` suffix, e.g. ``"Naha Airport"`` for+ both ``Airport.NAH`` and ``Airport.OKA``.++ """+ code = member.name.removeprefix("_")+ return member.value.removesuffix(f" ({code})")diff --git a/fli/search/_decoders.py b/fli/search/_decoders.pyindex 5a3b96e..2125995 100644--- a/fli/search/_decoders.py+++ b/fli/search/_decoders.py@@ -267,10 +267,17 @@ def _parse_datetime(date_arr: list[int], time_arr: list[int]) -> datetime:# Airline / Airport enums are immutable so each code maps to a single# member instance — cache the ``getattr`` walk so the parse hot path-# turns into a dict lookup. ``__members__`` is itself a dict, but going-# through ``getattr`` adds attribute-protocol overhead we don't need.-_AIRLINE_BY_CODE: dict[str, Airline] = {m.name: m for m in Airline}-_AIRPORT_BY_CODE: dict[str, Airport] = {m.name: m for m in Airport}+# turns into a dict lookup. Built from ``__members__`` (not ``for m in+# Airline``/``for m in Airport``) so every registered name resolves, even+# an alias: iterating the Enum itself silently skips alias members (two+# codes sharing the same human-readable name collapse into one Enum+# value), which used to make codes like Okinawa's ``OKA`` disappear from+# this dict entirely and get dropped as "unknown code". The generator now+# disambiguates duplicate names so aliases shouldn't occur in practice,+# but building from ``__members__`` keeps this dict correct even if that+# invariant is ever violated.+_AIRLINE_BY_CODE: dict[str, Airline] = dict(Airline.__members__)+_AIRPORT_BY_CODE: dict[str, Airport] = dict(Airport.__members__)def _parse_airline(code: str) -> Airline:diff --git a/scripts/generate_enums.py b/scripts/generate_enums.pyindex 8c97db0..b41171c 100644--- a/scripts/generate_enums.py+++ b/scripts/generate_enums.py@@ -28,11 +28,58 @@ iteration) is identical to the previous form."""import csv+from collections import Counterfrom pathlib import PathPROJECT_DIR = Path(__file__).parents[1].resolve()+def _disambiguate_names(entries: list[tuple[str, str]]) -> list[tuple[str, str]]:+ """Append IATA codes to duplicate names so every Enum value is unique.++ Python's ``Enum`` treats members with the same value as aliases — the+ second silently becomes an alias for the first. This function detects+ duplicate human-readable names and appends `` (CODE)`` to *all*+ members of each duplicate group (including the first) so every entry+ gets its own distinct Enum member.++ Entries with unique names are left untouched.+ """+ name_counts = Counter(name for _, name in entries)+ duplicates = {name for name, count in name_counts.items() if count > 1}+ if not duplicates:+ return entries+ return [(code, f"{name} ({code})" if name in duplicates else name) for code, name in entries]+++def _assert_unique(entries: list[tuple[str, str]], enum_name: str) -> None:+ """Raise ``ValueError`` if any sanitized code or final name repeats.++ Must run *after* :func:`_disambiguate_names` so it validates exactly+ what :func:`_write_enum_module` is about to emit as+ ``Enum(name, mapping)``: duplicate sanitized identifiers collide as+ dict keys (the later entry silently overwrites the earlier one), and+ duplicate names collide as dict values (Python's ``Enum`` silently+ turns the second member into an alias of the first — the original bug+ this script exists to prevent).+ """+ allow_digit_prefix = enum_name == "Airline"+ sanitized_codes = [_sanitize_code(code, allow_digit_prefix) for code, _ in entries]+ code_counts = Counter(sanitized_codes)+ dup_codes = sorted(code for code, count in code_counts.items() if count > 1)+ if dup_codes:+ raise ValueError(+ f"Duplicate sanitized {enum_name} codes after sanitization: {', '.join(dup_codes)}"+ )++ name_counts = Counter(name for _, name in entries)+ dup_names = sorted(name for name, count in name_counts.items() if count > 1)+ if dup_names:+ raise ValueError(+ f"Duplicate {enum_name} names remain after disambiguation: {', '.join(dup_names)}"+ )++def _sanitize_code(code: str, allow_digit_prefix: bool = False) -> str:"""Return a valid Python identifier for an IATA code.@@ -116,6 +163,8 @@ def generate_airport_enum() -> None:except (KeyError, csv.Error) as e:raise ValueError(f"Error reading CSV file: {e}") from e+ entries = _disambiguate_names(entries)+ _assert_unique(entries, enum_name="Airport")_write_enum_module(out_path,enum_name="Airport",@@ -159,6 +208,8 @@ def generate_airline_enum() -> None:])+ entries = _disambiguate_names(entries)+ _assert_unique(entries, enum_name="Airline")_write_enum_module(out_path,enum_name="Airline",diff --git a/tests/cli/test_utils.py b/tests/cli/test_utils.pyindex fe359e9..2f8f824 100644--- a/tests/cli/test_utils.py+++ b/tests/cli/test_utils.py@@ -579,3 +579,12 @@ def test_serialize_flight_result_extracted_currency_takes_precedence():payload = serialize_flight_result(flight, default_currency="CAD")assert payload["currency"] == "GBP"+++def test_format_airport_does_not_repeat_the_disambiguation_code():+ """Disambiguated names (e.g. "Naha Airport (OKA)") must not render the code twice."""+ from fli.cli.utils import format_airport+ from fli.models import Airport++ assert format_airport(Airport.OKA) == "OKA (Naha Airport)"+ assert format_airport(Airport.JFK).startswith("JFK (John F Kennedy")diff --git a/tests/core/test_airports.py b/tests/core/test_airports.pyindex 0e7a5e2..8d3719c 100644--- a/tests/core/test_airports.py+++ b/tests/core/test_airports.py@@ -139,3 +139,33 @@ class TestAirportMatch:except Exception:returnraise AssertionError("AirportMatch should reject score > 100")+++class TestDisambiguatedNamesStayInternal:+ """The " (CODE)" suffix that keeps Enum values unique must never reach users."""++ def test_search_results_show_the_plain_name(self):+ """Both airports called "Naha Airport" are returned under their own code."""+ from fli.core.airports import search_airports++ by_code = {m.code.name: m.name for m in search_airports("Naha Airport", limit=10)}+ assert by_code["OKA"] == "Naha Airport"+ assert by_code["NAH"] == "Naha Airport"++ def test_suffix_does_not_create_name_matches(self):+ """A code fragment must not match through the hidden suffix text."""+ from fli.core.airports import search_airports++ matches = [m for m in search_airports("(NC", limit=10) if m.match_type == "name"]+ assert matches == []++ def test_display_name_strips_only_its_own_code(self):+ """``display_name`` is a no-op for ordinary names."""+ from fli.models import Airline, Airport, display_name++ assert display_name(Airport.OKA) == "Naha Airport"+ assert display_name(Airport.JFK) == Airport.JFK.value+ assert Airline._1S.value.endswith(+ " (1S)"+ ) # digit-leading code: suffix shows "1S", not "_1S"+ assert display_name(Airline._1S) == Airline._1S.value.removesuffix(" (1S)")diff --git a/tests/models/test_enum_uniqueness.py b/tests/models/test_enum_uniqueness.pynew file mode 100644index 0000000..e086cb3--- /dev/null+++ b/tests/models/test_enum_uniqueness.py@@ -0,0 +1,47 @@+"""Tests guarding against alias regressions in the Airport / Airline enums.++``fli/models/airport.py`` and ``fli/models/airline.py`` are generated by+``scripts/generate_enums.py`` from CSV data. Enum *values* are human-readable+names, and Python's ``Enum`` silently turns a member with a value equal to an+earlier member's value into an *alias* of that earlier member — it never gets+its own ``__members__`` entry, and code that iterates ``for m in Airport``+(which skips aliases) can never see it. Concretely this used to mean+``Airport.OKA.name == "NAH"`` (searching for Okinawa, Japan actually resolved+to Naha, Indonesia) because both airports share the CSV name "Naha Airport".++These tests confirm the generator's disambiguation step (``_disambiguate_names``)+keeps every member distinct end to end, in the generated modules that ship.+"""++from __future__ import annotations++from fli.models import Airline, Airport+++class TestAirportNoAliases:+ """Every Airport member must be independently addressable."""++ def test_no_aliases(self):+ assert len(Airport.__members__) == len(list(Airport))++ def test_tri_and_psc_are_distinct(self):+ assert Airport.TRI.name == "TRI"+ assert Airport.PSC.name == "PSC"+ assert Airport.TRI.value != Airport.PSC.value++ def test_oka_and_nah_are_distinct(self):+ assert Airport.OKA.name == "OKA"+ assert Airport.NAH.name == "NAH"+ assert Airport.OKA.value != Airport.NAH.value++ def test_ntl_and_ncl_are_distinct(self):+ assert Airport.NTL.name == "NTL"+ assert Airport.NCL.name == "NCL"+ assert Airport.NTL.value != Airport.NCL.value+++class TestAirlineNoAliases:+ """Every Airline member must be independently addressable."""++ def test_no_aliases(self):+ assert len(Airline.__members__) == len(list(Airline))diff --git a/tests/scripts/test_generate_enums.py b/tests/scripts/test_generate_enums.pynew file mode 100644index 0000000..d48a752--- /dev/null+++ b/tests/scripts/test_generate_enums.py@@ -0,0 +1,97 @@+"""Tests for ``scripts/generate_enums.py``.++Loads the script as a module (it lives outside the ``fli`` package and has+no ``__init__.py``, so it can't be imported normally) to unit-test the+disambiguation and uniqueness-assertion helpers in isolation, without+needing to regenerate the real ``fli/models/airport.py`` / ``airline.py``.+"""++from __future__ import annotations++import importlib.util+from pathlib import Path++import pytest++REPO_ROOT = Path(__file__).resolve().parents[2]+SCRIPT_PATH = REPO_ROOT / "scripts" / "generate_enums.py"+++def _load_module():+ spec = importlib.util.spec_from_file_location("generate_enums", SCRIPT_PATH)+ assert spec and spec.loader+ module = importlib.util.module_from_spec(spec)+ spec.loader.exec_module(module)+ return module+++generate_enums = _load_module()+++class TestDisambiguateNames:+ """``_disambiguate_names`` must only touch members of a duplicate group."""++ def test_unique_names_untouched(self):+ entries = [("AAA", "Anaa Airport"), ("JFK", "John F. Kennedy Airport")]+ assert generate_enums._disambiguate_names(entries) == entries++ def test_all_members_of_duplicate_group_suffixed(self):+ # NAH and OKA share "Naha Airport" in data/airports.csv today — use+ # the same pattern (three-way duplicate) to prove every member of+ # the group is suffixed, not just the second-and-later ones.+ entries = [+ ("NAH", "Naha Airport"),+ ("OKA", "Naha Airport"),+ ("ZZZ", "Naha Airport"),+ ]+ result = generate_enums._disambiguate_names(entries)+ assert result == [+ ("NAH", "Naha Airport (NAH)"),+ ("OKA", "Naha Airport (OKA)"),+ ("ZZZ", "Naha Airport (ZZZ)"),+ ]++ def test_mixed_unique_and_duplicate(self):+ entries = [+ ("AAA", "Unique Airport"),+ ("NCL", "Newcastle Airport"),+ ("NTL", "Newcastle Airport"),+ ]+ result = generate_enums._disambiguate_names(entries)+ assert result == [+ ("AAA", "Unique Airport"),+ ("NCL", "Newcastle Airport (NCL)"),+ ("NTL", "Newcastle Airport (NTL)"),+ ]++ def test_empty_entries(self):+ assert generate_enums._disambiguate_names([]) == []+++class TestAssertUnique:+ """The generator must refuse to emit an enum with colliding members."""++ def test_passes_for_unique_codes_and_names(self):+ entries = [("AAA", "Anaa Airport"), ("JFK", "John F. Kennedy Airport")]+ generate_enums._assert_unique(entries, enum_name="Airport") # no raise++ def test_raises_on_duplicate_names_after_disambiguation(self):+ # Simulates a CSV that lists the same (code, name) pair twice —+ # ``_disambiguate_names`` appends the same code both times, so the+ # resulting names still collide and must be rejected.+ entries = [("ABC", "Foo Airport (ABC)"), ("ABC", "Foo Airport (ABC)")]+ with pytest.raises(ValueError, match="ABC"):+ generate_enums._assert_unique(entries, enum_name="Airport")++ def test_raises_on_duplicate_sanitized_codes(self):+ # "A.B" and "A B" both sanitize (non-alnum -> "_") to "A_B".+ entries = [("A.B", "Airport One"), ("A B", "Airport Two")]+ with pytest.raises(ValueError, match="A_B"):+ generate_enums._assert_unique(entries, enum_name="Airport")++ def test_allows_digit_prefixed_airline_codes(self):+ # Airline codes may start with a digit; the sanitizer prefixes an+ # underscore for those, which must not itself be flagged as a+ # collision between e.g. "3F" and "_3F".+ entries = [("3F", "Airline One"), ("4F", "Airline Two")]+ generate_enums._assert_unique(entries, enum_name="Airline") # no raisediff --git a/tests/search/test_decoders.py b/tests/search/test_decoders.pyindex bcdb56e..d4c19c3 100644--- a/tests/search/test_decoders.py+++ b/tests/search/test_decoders.py@@ -12,15 +12,45 @@ from datetime import datetimeimport pytest+from fli.models import Airline, Airportfrom fli.search._decoders import (+ _AIRLINE_BY_CODE,+ _AIRPORT_BY_CODE,_extract_booking_urls,_extract_fare_name,+ _parse_airport,_parse_emissions,_safe_airline,parse_booking_chunk,)+class TestAirportAirlineByCodeCompleteness:+ """``_AIRPORT_BY_CODE`` / ``_AIRLINE_BY_CODE`` must cover every enum code.++ Building these lookup dicts from ``for m in Airport`` (iterating the+ Enum) silently skips alias members, so codes that share a display name+ with an earlier code (e.g. ``OKA``/``NAH``, both "Naha Airport") were+ never inserted — rows for those airports/airlines were then dropped as+ "unknown code". The dicts must instead be built from ``__members__``,+ which includes every registered name.+ """++ def test_airport_by_code_contains_every_member_name(self):+ for name in Airport.__members__:+ assert name in _AIRPORT_BY_CODE++ def test_airline_by_code_contains_every_member_name(self):+ for name in Airline.__members__:+ assert name in _AIRLINE_BY_CODE++ def test_tri_resolves_to_tri_not_psc(self):+ assert _parse_airport("TRI") is Airport.TRI++ def test_oka_resolves_to_oka_not_nah(self):+ assert _parse_airport("OKA") is Airport.OKA++class TestSafeAirline:def test_known_code_returns_enum(self):from fli.models import Airline