Fix ternary union for literals by ilevkivskyi · Pull Request #18023 · python/mypy (original) (raw)

Fixes #18021

When I switched to (almost) always using unions as inferred from ternary expressions, I had a choice, because before we used either full context (i.e. l.h.s.) or the if type to infer the else type. After some playing I found the second one usually works better. But as we see this is not always the case, so I add some special-casing.