Skip to content

WIP: ShapeParser accept naics/psc as canonical (tango#2266)#28

Closed
makegov-hal[bot] wants to merge 1 commit into
mainfrom
issue-2266-shape-validator
Closed

WIP: ShapeParser accept naics/psc as canonical (tango#2266)#28
makegov-hal[bot] wants to merge 1 commit into
mainfrom
issue-2266-shape-validator

Conversation

@makegov-hal
Copy link
Copy Markdown

@makegov-hal makegov-hal Bot commented May 12, 2026

Summary

Tango server (makegov/tango#2259) now accepts both spellings as expand aliases. Pre-fix the SDK's ShapeParser did the opposite of the server — rejected canonical naics(...) / psc(...) and demanded the _code variant.

This PR makes the SDK agree with the server:

  • Mirrors the server's _EXPAND_ALIASES map locally in tango/shapes/parser.py. naics_code(...) and psc_code(...) are accepted as aliases for naics(...) / psc(...) when used as expansions (parens or wildcards). Bare scalar naics_code / psc_code are untouched — matching server semantics.
  • Added explicit naics / psc expand entries to Contract, Forecast, Opportunity, Notice, and Vehicle schemas in tango/shapes/explicit_schemas.py. IDV already had them.

Picked Option 2 (mirror alias map) over Option 1 (drop client-side validation) because the validator drives meaningful work locally (schema introspection, type hints).

Test plan

  • 11 new cases in TestShapeParserExpandAliases (tests/test_shapes.py)
  • 261/261 unit tests pass on Python 3.12 and 3.13

Note: the worktree's default venv is Python 3.14, which has pre-existing typing failures unrelated to this PR. Both supported versions (3.12, 3.13) are clean.

Base

main.

Refs

  • makegov/tango#2266 (tracking issue)
  • makegov/tango#2259 (server-side change that this companion fixes)

~ Hal

Tango server (makegov/tango#2259) now accepts both spellings as
expand aliases:

- `naics(code,description)` — canonical
- `naics_code(code,description)` — alias rewritten to `naics` at
  parse time
- Same pair for `psc(...)` / `psc_code(...)`.

Pre-fix the SDK's ShapeParser rejected the canonical server form
and demanded the `_code` alias — exactly opposite to the server.
Mirror the server's `_EXPAND_ALIASES` map locally so both spellings
are accepted client-side when used as expansions (with parens or
wildcards). Bare scalar leaves `naics_code` / `psc_code` are
untouched, matching server semantics.

Also added explicit `naics` / `psc` expand entries to Contract,
Forecast, Opportunity, Notice, and Vehicle schemas in
`tango/shapes/explicit_schemas.py` so the canonical form validates
locally too (IDV already had them).

Tests: 11 new cases in `TestShapeParserExpandAliases`. 261/261 unit
tests pass on Python 3.12 and 3.13. (Python 3.14 in the worktree's
default venv has pre-existing typing-related failures unrelated to
this change.)

Refs: makegov/tango#2266, makegov/tango#2259

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant