Add namespace-agnostic type resolution to NamespaceCatalog (#1528) - #1531
Draft
rly wants to merge 2 commits into
Draft
Add namespace-agnostic type resolution to NamespaceCatalog (#1528)#1531rly wants to merge 2 commits into
rly wants to merge 2 commits into
Conversation
Make get_spec, get_hierarchy, and is_sub_data_type accept namespace=None to search all loaded namespaces; add get_subtypes(data_type) that unions subtypes across namespaces; add type_key/type_keys properties reporting the catalog's data type key(s). Groundwork for validating files that use multiple extensions across namespaces (#608). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
rly
force-pushed
the
fix/1528-namespace-agnostic-resolution
branch
from
July 7, 2026 08:25
15fdd21 to
4810baa
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1531 +/- ##
==========================================
- Coverage 93.21% 93.19% -0.03%
==========================================
Files 41 41
Lines 10186 10213 +27
Branches 2104 2114 +10
==========================================
+ Hits 9495 9518 +23
- Misses 414 416 +2
- Partials 277 279 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…atch The namespace=None lookups resolve a data type by bare name and return the first match, mirroring TypeMap.get_dt_container_cls. Document that an explicit namespace is needed to disambiguate a name defined differently in more than one namespace, and remove get_subtypes: a cross-namespace subtype union conflates distinct same-named types, so it is unsafe as a validation primitive. Add a collision test showing explicit-namespace resolution stays correct. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
rly
marked this pull request as draft
July 7, 2026 16:35
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.
Motivation
Closes #1528. Groundwork for #608 (validating files that use multiple extensions across namespaces).
Cross-namespace consumers sometimes need to resolve a data type (its spec or its ancestor hierarchy) from only a bare
data_type, without knowing which namespace defines it.NamespaceCatalogpreviously only exposed namespace-scoped lookups. The build layer already has the analogous namespace-agnostic convenience inTypeMap.get_dt_container_cls(data_type, namespace=None).Changes
Additive, no breaking changes. On
NamespaceCatalog:get_spec(namespace=None, data_type=...): whennamespace is None, search all loaded namespaces and return the spec from the first namespace that defines the type.get_hierarchy(namespace=None, data_type=...): whennamespace is None, return the owning namespace's hierarchy; empty tuple if no loaded namespace defines the type.is_sub_data_type(namespace=None, ...):namespaceoptional for symmetry.type_key/type_keysproperties (new): report the catalog's data type key(s) from its spec classes.Existing two-argument
get_spec(namespace, data_type)/get_hierarchy(namespace, data_type)/is_sub_data_type(namespace, ...)calls (positional and keyword) are unchanged.Note on colliding type names across namespaces
Different namespaces can define different types that share a name. The read/construct path differentiates them because every typed builder stores a
namespaceattribute and is resolved by(namespace, data_type)(TypeMap.get_cls→get_builder_ns+get_dt_container_cls(dt, ns)). Thenamespace=Nonelookups added here resolve by bare name and return the first match, which assumes a name identifies the same type in every namespace (the same assumptionTypeMap.get_dt_container_cls(namespace=None)already makes). This is documented on each method: pass an explicit namespace to disambiguate. To keep this collision-safe, downstream validation should dispatch each builder by its stored(namespace, data_type)rather than by bare name (tracked in #1529).Testing
tests/unit/spec_tests/test_multi_namespace_resolution.py: a shared dependency namespace plus two independent extension namespaces, including two different types that reuse the nameWidget. Asserts search-all resolution, the unchanged two-argument behavior, the type-key properties, and that an explicit namespace disambiguates the colliding name (whilenamespace=Nonereturns the documented first match).spec_tests,build_tests,common, andvalidator_testssuites pass (1196 passed, 53 skipped).ruffclean.How to test
Checklist
CHANGELOG.mdwith your changes?ruff)🤖 Generated with Claude Code