Summary
When using a conditional check to cover the case where you might divide by zero, ty raises a division-by-zero error. MyPy will pass.
Example: Playground
a: int = 1
b: int = 0
c = a / b if b > 0 else 0
if b > 0:
c = a / b
else:
c = 0
# mypy passes in both
# ty fails in both:
# error[division-by-zero]: Cannot divide object of type `Literal[1]` by zero
# --> type_example.py:4:5
# |
# 2 | b: int = 0
# 3 |
# 4 | c = a / b if b > 0 else 0
# | ^^^^^
# |
# info: rule `division-by-zero` is enabled by default`
Version
ty 0.0.1-alpha.5 (3b726d8 2025-05-17)