Repository navigation
Preserve caller baskets during legacy int-to-float casting - #783
Open
pengpengyi92 wants to merge 2 commits into
Open
pengpengyi92 wants to merge 2 commits into
pengpengyi92 wants to merge 2 commits into
Conversation
Signed-off-by: PP1 <74917296+pengpengyi92@users.noreply.github.com>
pengpengyi92
requested review from
AdamGlustein,
alexddobkin,
robambalu and
svatasoiu
as code owners
October 30, 2026 01:03
Signed-off-by: PP1 <74917296+pengpengyi92@users.noreply.github.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
Addresses the remaining legacy-resolver behavior in #181. On current main, with
CSP_PYDANTICset to the empty string before importing CSP, passing an int list/dict basket to a float-basket input still replaces entries in the caller's container with float-cast edges. Reusing that basket as int input can then fail. The Pydantic path already preserves these inputs and is unchanged.Make a shallow copy on the first required cast, update the resolved basket instead of the original, and reuse that copy for subsequent casts. Baskets that require no cast do not incur a copy in this path. No C++ or public API changes.
Regression tests
11.0.c7d0aded32cf9b6c969490a9a7a55376476e7464, the exact two new tests fail under legacy validation due to mutated edge identity. With this patch both pass; under Pydantic they pass before and after.This branch is based directly on upstream main and does not include #779.
Verification
Windows x64; Python 3.12.14; Pydantic 2.14.1; pytest 9.1.1.
145 passed, 2 skipped, exit 0 (plus 5 passing unittest subtests).
Legacy mode must be selected before importing CSP, for example:
61 passed, 1 explicitly deselected, exit 0. Without excluding the known Literal case, the three typing/parsing files give 48 passed, 1 failed. Unmodified upstream in the same environment gives 46 passed, 1 failed, with the identical
test_literal_typingfailure. That pre-existing failure is not fixed or hidden by this PR.Ruff check/format on the changed files and
git diff --check: PASS.Local runs use checked-out Python source with official CSP 0.19.1 Windows wheel native libraries. No native source rebuild, Linux/macOS matrix or full service-dependent suite was run. Runtime/memory performance has not been benchmarked. Maintainer CI and review remain required; no upstream acceptance is implied.