[ty] ensure union normalization really normalizes by carljm · Pull Request #20147 · astral-sh/ruff (original) (raw)
added the ty
Multi-file analysis & type inference
label
carljm marked this pull request as ready for review
Co-authored-by: Alex Waygood Alex.Waygood@Gmail.com
carljm deleted the cjm/union-norm branch
dcreager added a commit that referenced this pull request
- main: (28 commits)
[ty]
__class_getitem__is a classmethod (#20192) [ty] Support__init_subclass__(#20190) Update dependency ruff to v0.12.11 (#20184) Update rui314/setup-mold digest to 725a879 (#20181) Update CodSpeedHQ/action action to v3.8.1 (#20183) Update cargo-bins/cargo-binstall action to v1.15.3 (#20182) Update Rust crate camino to v1.1.12 (#20185) Update Rust crate clap to v4.5.46 (#20186) Update Rust crate mimalloc to v0.1.48 (#20187) [ty] Sync vendored typeshed stubs (#20188) [ty] improve cycle-detection coverage for apply_type_mapping (#20159) [ty] don't assume that deferred type inference means deferred name resolution (#20160) Less confidently mark f-strings as empty when inferring truthiness (#20152) [ty] skip a slow seed in fuzzer (#20161) Revert "[ty] Useinvalid-assignmenterror code for invalid assignments toClassVars" (#20158) [ty] add six ecosystem projects to good.txt (#20157) [ty] Useinvalid-assignmenterror code for invalid assignments toClassVars (#20156) [ty] minor TypedDict fixes (#20146) [ty] ensure union normalization really normalizes (#20147) [ty] typecheck dict methods forTypedDict(#19874) ...
second-ed pushed a commit to second-ed/ruff that referenced this pull request
Summary
Now that we have Type::TypeAlias, which can wrap a union, and the
possibility of unions including non-unpacked type aliases (which is
necessary to support recursive type aliases), we can no longer assume in
UnionType::normalized_impl that normalizing each element of an
existing union will result in a set of elements that we can order and
then place raw into UnionType to create a normalized union. It's now
possible for those elements to themselves include union types (unpacked
from an alias). So instead, we need to feed those elements into the full
UnionBuilder (with alias-unpacking turned on) to flatten/normalize
them, and then order them.
Test Plan
Added mdtest.
Co-authored-by: Alex Waygood Alex.Waygood@Gmail.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
[ Show hidden characters]({{ revealButtonHref }})