Summary
Howdy!
So I was reviewing a PR to the attrs repo just now. This PR seems to be running into an issue with ty so I wanted to dig deeper.
Not to get bogged down in the weeds of how attrs works, here's a small repro: https://play.ty.dev/ee4a7f0b-5084-4477-834f-406106d62381
So the problem is when you call make_gt_validator(0), the result is Callable[[Literal[0], bool] instead of Callable[[int], bool]. The ty behavior here actually looks correct to me, so I'm very willing to concede the type hints are wrong. But then my issue is how to type this to get the int callable instead. Would love your thoughts on this.
Version
ty 0.0.21 (c1ad9f2 2026-03-06)
Summary
Howdy!
So I was reviewing a PR to the attrs repo just now. This PR seems to be running into an issue with ty so I wanted to dig deeper.
Not to get bogged down in the weeds of how attrs works, here's a small repro: https://play.ty.dev/ee4a7f0b-5084-4477-834f-406106d62381
So the problem is when you call
make_gt_validator(0), the result isCallable[[Literal[0], bool]instead ofCallable[[int], bool]. The ty behavior here actually looks correct to me, so I'm very willing to concede the type hints are wrong. But then my issue is how to type this to get theintcallable instead. Would love your thoughts on this.Version
ty 0.0.21 (c1ad9f2 2026-03-06)