You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lambda contextual typing doesn't work with union of callables #219
ERROR 3:60-67: `+` is not supported between `int` and `Literal['1']`
Argument `Literal['1']` is not assignable to parameter with type `int` in function `int.__add__` [[bad-argument-type](https://pyrefly.org/en/docs/error-kinds/#bad-argument-type)]
changed the title [-]False positive in lambda annotated w/ Callable[/-][+]Lambda contextual typing doesn't work with union of callables[/+]on Feb 28, 2026
Activity
yangdanny97 commentedon May 16, 2025
The way we currently do contextual typing doesn't handle unions well in some cases, it's on our roadmap to improve the behavior here.
samwgoldman commentedon Jul 16, 2025
related to #164
stroxler commentedon Aug 28, 2025
Issue #164 is now closed, but the fix was specific to TypedDict
This is probably related to (perhaps identical to) #793
yangdanny97 commentedon Feb 27, 2026
The error reproduces even without a union:
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0BhVFCipssADropYRIOGjxMANrLWDALoAaTuk10AvHVE1smVHXxz8dANR0JIAIyOQWkAFcG0OCXKIQAGI6AFVvKAgmOjAPdABjb1x0OCkpTBgwaN4aVAYAfXQPUxhKAAorXQYASjoAWgA%2BOjgGSkQpOg66ShgGD0p0aMcAOSLsErlgfABfRyk3EDJusChSQgZaKApggAVSJZWmjBwCOjikyDY%2B3IgkwilggGUYGDoACwYGYjhEAHofxYyK0IvDYPxg6B%2BmFwcTgPzO6AuV0SEKylDoqAAbqhoGJYKdzhBLpRrkk6LhiMjfFIyAxXklahiSnAbgMjI4AMyEJwAJlm6BAU3cqASEEZADFoDAKGgsHgiGQBUA
[-]Lambdas don't play well with unions of callables[/-][+]False positive in lambda annotated w/ Callable[/+]rchen152 commentedon Feb 27, 2026
Wait, isn't that a legitimate error without the union? Adding an int and a str.
yangdanny97 commentedon Feb 28, 2026
oh lol, i didn't see the quotes around the 1
[-]False positive in lambda annotated w/ Callable[/-][+]Lambda contextual typing doesn't work with union of callables[/+]Add github workflow for v1 issue ranking
Add github workflow for v1 issue ranking