astral-sh
ruff
BlogDocsChangelog

[ty] Narrow types after NoReturn calls in if branches

#21819Closed
Comparing
alex:fix-noreturn-narrowing
(
6c73a5c
) with
main
(
6e0e49e
)
CodSpeed Performance Gauge
-10%
Regressions
1
Untouched
12
Skipped
30
Archived
9

Benchmarks

Skipped (30)

Failed

hydra-zen
crates/ruff_benchmark/benches/ty.rs::project::hydra::project
Regression
CodSpeed Performance Gauge
-6%
1.2 s1.3 s

Passed

ty_micro[complex_constrained_attributes_1]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_complex_constrained_attributes_1
CodSpeed Performance Gauge
0%
68.1 ms68.1 ms
ty_micro[complex_constrained_attributes_3]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_complex_constrained_attributes_3
CodSpeed Performance Gauge
0%
71.7 ms71.8 ms
ty_micro[many_tuple_assignments]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_tuple_implicit_instance_attributes
CodSpeed Performance Gauge
0%
67.9 ms68 ms
ty_micro[many_string_assignments]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_many_string_assignments
CodSpeed Performance Gauge
0%
85.8 ms85.9 ms
ty_micro[many_tuple_assignments]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_many_tuple_assignments
CodSpeed Performance Gauge
0%
66.6 ms66.8 ms
ty_micro[complex_constrained_attributes_2]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_complex_constrained_attributes_2
CodSpeed Performance Gauge
-1%
67.8 ms68.1 ms
DateType
crates/ruff_benchmark/benches/ty.rs::project::datetype::project
CodSpeed Performance Gauge
-1%
254.6 ms256 ms
ty_check_file[cold]
crates/ruff_benchmark/benches/ty.rs::check_file::benchmark_cold
CodSpeed Performance Gauge
-1%
138.2 ms139.3 ms
ty_check_file[incremental]
crates/ruff_benchmark/benches/ty.rs::check_file::benchmark_incremental
CodSpeed Performance Gauge
-1%
6.9 ms7 ms
anyio
crates/ruff_benchmark/benches/ty.rs::project::anyio::project
CodSpeed Performance Gauge
-2%
1.4 s1.5 s
ty_micro[many_enum_members]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_many_enum_members
CodSpeed Performance Gauge
-3%
126.4 ms130 ms
attrs
crates/ruff_benchmark/benches/ty.rs::project::attrs::project
CodSpeed Performance Gauge
-3%
454.3 ms467.1 ms

Commits

Click on a commit to change the comparison range
Base
main
6e0e49e
-10.26%
[ty] Narrow types after NoReturn calls in if branches When a branch calls a NoReturn function, use the negation of the condition to narrow types after the if statement. For example, after `if val is None: sys.exit()`, `val` is now correctly narrowed to `int` instead of `int | None`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
6c73a5c
27 days ago
by alex
© 2026 CodSpeed Technology
Home Terms Privacy Docs