"invalid-assignment" with `operator.mul` but not multiplication operator
Author: hunterhoganCreated Sep 25, 2026Updated Sep 30, 2026
Labelsbuggenericsset-theoretic typesconstraint-solver
Question
There are too many moving parts for me to figure out where the problem is:
- PEBCAK
- typeshed
- #2799
- Ought to create a bug report
- Something else
From my perspective, y'all have done a great job addressing 2799: I have not seen a 2799-esque issue in my code for two or three months. Therefore, I'm sharing this in case it's a novel issue--and because I can't figure out whether it's 2799 or not.
Object of type `Fraction | complex` is not assignable to `Fraction` (invalid-assignment) [Ln 15, Col 25]
Declared type [Ln 15, Col 14]
info: element `int` of union `Fraction | int | float* | complex*` is not assignable to `Fraction`main.py:
from operator import mul
from math import comb
from fractions import Fraction
def C(n: int) -> Fraction:
return Fraction(comb(2 * n, n) / (n + 1))
def 工antiCatalan(sub_antiCatalan: int, 次antiCatalan: int) -> int:
match 次antiCatalan:
case 3:
returnMe: Fraction = C(sub_antiCatalan) * 2
case 2:
returnMe: Fraction = 2 * C(sub_antiCatalan)
case 1:
returnMe: Fraction = mul(C(sub_antiCatalan), 2)
case _:
returnMe: Fraction = mul(2, C(sub_antiCatalan))
return int(returnMe)
ty.json:
{
"environment": {
"python-version": "3.14"
},
"analysis": {
"strict-equality-semantics": false,
"strict-generic-narrowing": false
},
"rules": {
"experimental-syntax": "ignore",
"undefined-reveal": "ignore"
}
}Version
ty 0.0.83 (9c214798c 2026-09-21)
Source: astral-sh/ty