astral-sh
ruff
BlogDocsChangelog

[ty] Narrow types after NoReturn calls in if branches

#21819
Comparing
alex:fix-noreturn-narrowing
(
32fd9fe
) with
main
(
ef45c97
)
CodSpeed Performance Gauge
-9%
Regressions
2
Untouched
15
Skipped
35

Benchmarks

Skipped (35)

Failed

medium[pandas]
crates/ruff_benchmark/benches/ty_walltime.rs
Regression
CodSpeed Performance Gauge
-9%
69.3 s76 s
hydra-zen
crates/ruff_benchmark/benches/ty.rs::project::hydra::project
Regression
CodSpeed Performance Gauge
-6%
1.2 s1.3 s

Passed

multithreaded[altair]
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
+1%
1.6 s1.6 s
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 ms
ty_micro[many_enum_members]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_many_enum_members
CodSpeed Performance Gauge
0%
126.4 ms126.6 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.1 ms
ty_micro[complex_constrained_attributes_2]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_complex_constrained_attributes_2
CodSpeed Performance Gauge
0%
67.7 ms67.9 ms
ty_micro[many_string_assignments]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_many_string_assignments
CodSpeed Performance Gauge
0%
85.8 ms86.1 ms
DateType
crates/ruff_benchmark/benches/ty.rs::project::datetype::project
CodSpeed Performance Gauge
0%
254.3 ms255.2 ms
medium[colour-science]
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
0%
96.6 s96.9 s
ty_micro[many_tuple_assignments]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_many_tuple_assignments
CodSpeed Performance Gauge
0%
66.6 ms66.9 ms
ty_micro[complex_constrained_attributes_3]
crates/ruff_benchmark/benches/ty.rs::micro::benchmark_complex_constrained_attributes_3
CodSpeed Performance Gauge
-1%
71.7 ms72.1 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
-1%
1.4 s1.5 s
ty_check_file[cold]
crates/ruff_benchmark/benches/ty.rs::check_file::benchmark_cold
CodSpeed Performance Gauge
-1%
138.2 ms140.1 ms
attrs
crates/ruff_benchmark/benches/ty.rs::project::attrs::project
CodSpeed Performance Gauge
-3%
454.4 ms469.1 ms
medium[static-frame]
crates/ruff_benchmark/benches/ty_walltime.rs
CodSpeed Performance Gauge
-4%
20.3 s21 s

Commits

Click on a commit to change the comparison range
Base
main
ef45c97
-8.71%
[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>
32fd9fe
4 hours ago
by alex
© 2025 CodSpeed Technology
Home Terms Privacy Docs