Skip to content

Extract shared matching helpers into matching_common - #574

Merged
jrhoads merged 2 commits into
devfrom
quickwin/matching-common
Sep 25, 2026
Merged

jrhoads merged 2 commits into
devfrom
quickwin/matching-common

Conversation

@jrhoads

@jrhoads jrhoads commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Move normalize, get_country_codes, to_region, and check_latin_chars into new rorapi/common/matching_common.py (shared by multi-node and single-search matching).
  • Re-export those symbols from matching.py and matching_single_search.py so existing imports keep working.
  • Country map still comes from countries.txt.

Intentional get_country_codes change

  • The two modules previously disagreed: matching.py used max([...]) (can ValueError on empty token lists); matching_single_search.py used max([...]+[0]).
  • Shared matching_common.get_country_codes now uses the defensive + [0] form so empty/non-alpha affiliations return [] instead of raising — preserving single-search behavior and hardening multi-search.
  • The other three helpers remain identical moves.

Test plan

  • Matching unit cases (CountriesTestCase, NormalizeTestCase, and related matching utils) via Django test loader
  • Unit test: empty/non-alpha input ("", "123", etc.) returns [] without ValueError
  • CI tests_unit on this PR (flow-guard + test-pr / test green)
  • ruff expected-red until Wave 5 (continue-on-error: true; not fixed in this PR)
Open in Web Open in Cursor 

cursoragent and others added 2 commits September 25, 2026 14:22
Move normalize, get_country_codes, to_region, and check_latin_chars
into rorapi.common.matching_common and re-export from matching and
matching_single_search so existing imports keep working.

Co-authored-by: Joseph Rhoads <jrhoads@users.noreply.github.com>
Use max([...]+[0]) so empty/non-alpha affiliations return [] instead
of raising ValueError, matching prior single-search behavior.

Co-authored-by: Joseph Rhoads <jrhoads@users.noreply.github.com>
@cursor
cursor Bot force-pushed the quickwin/matching-common branch 2 times, most recently from 20ca4de to 7c4641e Compare September 25, 2026 14:22
@jrhoads
jrhoads marked this pull request as ready for review September 25, 2026 14:31
@jrhoads
jrhoads merged commit 3bff498 into dev Sep 25, 2026
4 of 6 checks passed
@jrhoads
jrhoads deleted the quickwin/matching-common branch September 25, 2026 14:31
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