Make imprecise constraints handling more robust by ilevkivskyi · Pull Request #16502 · python/mypy

Fixes #16485

My initial implementation of imprecise constraints fallback was really fragile and ad-hoc, and I now see several edge case scenarios where we may end up using imprecise constraints for a ParamSpec while some precise ones are available. So I re-organized it: now we just infer everything as normally, and filter out imprecise (if needed) at the very end, when we have the full picture. I also fix an accidental omission in expand_type().