SIGN IN SIGN UP
astral-sh / ruff UNCLAIMED

An extremely fast Python linter and code formatter, written in Rust.

0 0 41 Rust

[ty] Modernize setup of union types in mdtests (#25291)

Remember when we wrote `x = 1 if flag else None` because we couldn't
infer types from annotated parameters and/or couldn't understand union
type annotations? This PR modernizes our mdtests to simply use annotated
function parameters in those cases (I manually rejected some rewrites
when the new style was less clear, for example when the generated union
type itself was hard to spell).

The motivation for this is to set a better precedent for agents, as I've
seen them repeating that `x if flag else y` pattern, which is really
unnecessary, longer and harder to read in most cases.
D
David Peter committed
c714e84952510696c05ec21b0158a3548898f594
Parent: 8a8e35e
Committed by GitHub <noreply@github.com> on 5/21/2026, 1:39:46 PM