mirror of https://github.com/astral-sh/ruff
## Summary Eagerly evaluate the elements of a PEP 604 union in value position (e.g. `IntOrStr = int | str`) as type expressions and store the result (the corresponding `Type::Union` if all elements are valid type expressions, or the first encountered `InvalidTypeExpressionError`) on the `UnionTypeInstance`, such that the `Type::Union(…)` does not need to be recomputed every time the implicit type alias is used in a type annotation. This might lead to performance improvements for large unions, but is also necessary for correctness, because the elements of the union might refer to type variables that need to be looked up in the scope of the type alias, not at the usage site. ## Test Plan New Markdown tests |
||
|---|---|---|
| .. | ||
| conditionals | ||
| assert.md | ||
| assignment.md | ||
| bool-call.md | ||
| boolean.md | ||
| complex_target.md | ||
| hasattr.md | ||
| isinstance.md | ||
| issubclass.md | ||
| match.md | ||
| post_if_statement.md | ||
| truthiness.md | ||
| type.md | ||
| type_guards.md | ||
| while.md | ||