Skip to content

fix(connector): a county asks which of its districts - #240

Draft
billlyzhaoyh wants to merge 1 commit into
mainfrom
fix/connector-counties
Draft

billlyzhaoyh wants to merge 1 commit into
mainfrom
fix/connector-counties

Conversation

@billlyzhaoyh

@billlyzhaoyh billlyzhaoyh commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #236.

The problem

The connector's describe_place, which the chat assistant uses, describes one council at a time. Given a county's name, it fell back to matching part of a council's name, so the answer depended on which district names happened to hold the county's:

  • "Gloucestershire" was found as South Gloucestershire, a different council outside the county.
  • "Hampshire" was found as East Hampshire, one of its districts, as if it were the whole county.
  • "Kent" and "Essex" were not found.

The fix

A county is now answered as London is (#234): choose, listing all its districts.

  • Which counties. All 21 counties in England with two tiers of council, such as Kent, Essex and Gloucestershire, join London in the table of areas larger than one council. "Kent County Council" and "County of Essex" are matched as "Kent" and "Essex".
  • Where the districts come from. They come from the county lookup the package already ships (areas.local_authority_lookup("county")), so no list is kept by hand. As with London, the list is complete and isn't cut to the usual 10: Essex, Kent and Lancashire have 12 each.
  • The message. It now says the area "is split into" that many local authorities. It used to say the area "has" that many councils, which is wrong for a county, because the county council is a council too.
  • Unchanged. A district is still found by its own name (South Gloucestershire, East Hampshire), and so is a unitary council (Cornwall, North Yorkshire). London, the City of London and "Newcastle" give the same answers as before.

Nothing public changes.

Tests

  • New: test_a_county_asks_which_of_its_districts checks that "Gloucestershire" lists its 6 districts, and not South Gloucestershire.
    • I saw it fail on main's connector code for the reason in the issue: "Gloucestershire" came back found, as South Gloucestershire.
    • For that, the small England in the test data gained a South Gloucestershire neighbourhood. Like the City of London row, it has no residents, so the shares of England's residents that other tests check are unchanged.
  • Checks run locally, on top of main f8c11ad (after fix(connector): London as a whole asks which of its councils #234). All passed:
    • ruff check
    • ruff format --check
    • ast-grep scan
    • ty check src
    • pytest (1,296 passed)
    • mkdocs build --strict
  • Run on real data: each of the 21 counties gives choose with all its districts, from Cambridgeshire (5) to Worcestershire (6). "London" still lists 33. "City of London", "Hackney", "South Gloucestershire", "East Hampshire", "Cornwall" and "North Yorkshire" are found.
  • I did not run the live source checks (-m live). Nothing here reads a new source.

Found in review, not changed here

  • Older county names, such as Berkshire, Sussex and Bedfordshire, aren't in the lookup. They still find one council whose name holds them, so "Berkshire" gives West Berkshire. They are left for a later change. The docs now say so.
    • A more general fix would mark an answer matched on part of a name as such, so the assistant checks before it passes on the figures. That would also cover these names. It could be a follow-up issue.
  • A county's own code, such as Kent's E10000016, still gives not_found. That's honest, and the issue is about names.

AI tools

Claude Code wrote the change, the test and this description, and ran the code review and simplify passes.

describe_place describes one council at a time. Given a county's name,
it fell back to matching part of a council's name, so "Gloucestershire"
was found as South Gloucestershire, a different council, "Hampshire" as
East Hampshire, one of its districts, and "Kent" was not found.

Each of England's 21 counties with two tiers of council is now in the
table of areas larger than one council that London is in, so its name
answers choose and lists all its districts. The districts come from the
county lookup the package ships, so no list is kept by hand and none is
cut to the usual 10. "Kent County Council" is matched as "Kent".

The choose message now says the area is split into that many local
authorities: a county also has its own council, so "has 6 councils" was
wrong for Gloucestershire.

Unchanged: a district, a unitary council and London are found as
before. Older county names, such as Berkshire, are not in the lookup and
still find a council whose name holds them.

Signed-off-by: billlyzhaoyh <billlyzhaoyh@users.noreply.github.com>
Github-Issue: #236
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.2

QR code for preview link

🚀 View preview at
https://KindTechUK.github.io/uk-open-data/pr-preview/pr-240/

Built to branch gh-pages at 2026-12-02 18:36 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

This branch has not been deployed

No deployments
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.

connector: a county's name is answered with one of its districts, or a council outside it

1 participant