Skip to content

feat(weather): disambiguate city lookup with a country filter - #477

Merged
Eigenwise merged 1 commit into
Eigenwise:mainfrom
Afloat16:feat/weather-country-filter-20261117
Nov 17, 2026
Merged

Eigenwise merged 1 commit into
Eigenwise:mainfrom
Afloat16:feat/weather-country-filter-20261117

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Summary

City-name lookup always takes the first global geocoding result. When several countries contain a city with the same name, callers cannot explicitly restrict the lookup and can receive a forecast for the wrong location.

Add an optional country_code input for the documented Open-Meteo countryCode parameter. Accept a two-letter ISO-style code and send it uppercase. The geocoder applies this filter before its existing one-result limit, and the forecast uses the selected location's coordinates. A country with no matching city produces the existing lookup error instead of falling back to a different country's forecast.

Omitting the field keeps global lookup. Explicit latitude/longitude input still bypasses geocoding. The README documents both behaviors and an ambiguous-city example.

Validation

  • Fourteen regression/control cases on unchanged main: 12 failed, 2 passed.
  • Complete weather tool suite: 26 passed, Python 3.12.14.
  • Native requests against a local HTTP geocoding/forecast service verify two same-name cities in different countries, exact forecast coordinates, lowercase normalization, language preservation, absent filters, empty country-specific results and explicit coordinates.
  • Invalid country-filter shapes fail input validation before lookup. No live weather service is called.
  • Black 24.10, repository Flake8 and git diff --check pass.

API reference: Open-Meteo geocoding parameters.

@Eigenwise
Eigenwise merged commit 0205304 into Eigenwise:main Nov 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants