Skip to content

Check the codes in station corrections against ISO - #1624

Merged
frenck merged 1 commit into
mainfrom
frenck/corrections-check-codes
Oct 2, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/corrections-check-codes

Conversation

@frenck

@frenck frenck commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Breaking change

None. Tests only.

Proposed change

The schema in radios.corrections checks the shape of codes, like ^[A-Z]{2}-[A-Z0-9]{1,3}$ for a region. That lets codes through that look right but do not exist. While porting the radio-database proposals, 21 Hungarian ones used HU-BP for Budapest, which is HU-BU, and one Greek one used GR-1, an old code that was removed. I caught those by hand (#1606); this makes the test suite catch them.

A new test checks every shipped correction file against pycountry, which is already a dependency:

  • The country folder is a real country.
  • A region code exists, and lies in the countrycode of the same correction when it sets one.
  • Every language code exists, as two or three letters.

The check lives in the tests, not in the schema: an In(...) with every region code would put thousands of codes into schema.json. A second test feeds the helper a few wrong codes, so it is known to catch them.

All 145 correction files on main pass. What it cannot check: whether a region matches the country of the station itself when the correction does not set countrycode, since that country lives in the live API and the tests stay offline.

Type of change

  • Dependency or tooling upgrade
  • Bugfix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Deprecation (replaces or removes a feature, with a migration path)
  • Breaking change (a fix or feature that changes existing behavior)
  • Code quality, refactor, or test-only change
  • Documentation only

Additional information

Checklist

  • I fully understand the code in this pull request and can explain every line, including any AI-assisted changes.
  • The change is covered by tests, and poetry run pytest passes locally. A pull request cannot be merged unless CI is green.
  • poetry run prek run --all-files passes (lint, format, and type checks).
  • No commented-out or dead code is left in the pull request.

The schema only checks the shape of country, region and language codes.
Some proposals upstream use codes that look right but do not exist, like
HU-BP for Budapest, which is HU-BU. Check the shipped corrections against
pycountry: the country folder, the region (within its country), and every
language code.
@frenck frenck added the maintenance Generic maintenance tasks. label Oct 2, 2026
@frenck
frenck merged commit ea0be5f into main Oct 2, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Generic maintenance tasks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant