fix(schema): fix pre-existing pyright errors in BaseValueSchema and constrained builders#83
Open
fix(schema): fix pre-existing pyright errors in BaseValueSchema and constrained builders#83
Conversation
…try builders Adds removal support to NodeRegistryBuilder and ValueRegistryBuilder with a missing_ok parameter (default false). In lazy builders, removals are stored separately and applied after all additions at build time, so a removal always wins regardless of call order. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lue builders Two pre-existing issues introduced in #76: 1. BaseValueSchema.value_type used validation_alias/serialization_alias with "x-value-type", which pyright's Pydantic plugin can't handle (non-identifier alias). Replaced with a plain field and manual x-value-type <-> value_type translation in the existing model_validator and model_serializer. 2. _build_constrained_sequence_cls and _build_constrained_map_cls created TypeVars inside function bodies and used them as generic parameters in type() calls. Moved TypeVar to module scope and added type: ignore comments on the dynamic type() lines that pyright cannot statically analyze. Also updates two tests that constructed IntegerValueSchema via **{"x-value-type": ...} kwargs (not valid Python identifiers) to use model_validate() instead. Co-Authored-By: Claude Sonnet 4.6 <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
Fixes 22 pre-existing pyright errors introduced in #76 (
feat(values): constrained Value subclasses, x-value-type field, and $defs safety).Two root causes:
BaseValueSchema.value_typealias: The field usedvalidation_alias="x-value-type"+serialization_alias="x-value-type", but pyright's Pydantic plugin can't handle non-identifier aliases and misreportedvalue_typeas a required parameter. Fixed by making it a plain field and doing thex-value-type↔value_typetranslation manually in the already-existingmodel_validatorandmodel_serializer.TypeVar in function body:
_build_constrained_sequence_clsand_build_constrained_map_clscreated aTypeVarinside the function body and used it as a generic parameter intype()calls. Pyright doesn't support TypeVars defined in function scope as generic parameters. Fixed by moving_T_itemto module scope and adding# type: ignoreon the dynamictype()lines (which pyright can't statically analyze by design).Also updates two tests that passed
x-value-typevia**{...}kwargs (invalid Python identifier) to usemodel_validate()instead.Test plan
uv run pyrightreports 0 errorsuv run pytest— 413 passed, 1 xfaileduv run ruff check .— no issues🤖 Generated with Claude Code