WIP: ShapeParser accept naics/psc as canonical (tango#2266)#28
Closed
makegov-hal[bot] wants to merge 1 commit into
Closed
WIP: ShapeParser accept naics/psc as canonical (tango#2266)#28makegov-hal[bot] wants to merge 1 commit into
makegov-hal[bot] wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tango server (
makegov/tango#2259) now accepts both spellings as expand aliases. Pre-fix the SDK'sShapeParserdid the opposite of the server — rejected canonicalnaics(...)/psc(...)and demanded the_codevariant.This PR makes the SDK agree with the server:
_EXPAND_ALIASESmap locally intango/shapes/parser.py.naics_code(...)andpsc_code(...)are accepted as aliases fornaics(...)/psc(...)when used as expansions (parens or wildcards). Bare scalarnaics_code/psc_codeare untouched — matching server semantics.naics/pscexpand entries toContract,Forecast,Opportunity,Notice, andVehicleschemas intango/shapes/explicit_schemas.py.IDValready 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
TestShapeParserExpandAliases(tests/test_shapes.py)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