python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.42k stars 2.82k forks source link

Get rid of make_simplified_union() except in error messages #8624

Open ilevkivskyi opened 4 years ago

ilevkivskyi commented 4 years ago

It used to cause various issues and is still causing known bugs (like false negatives in per-file strict optional when map_instance_to_supertype() is involved). Ideally we should replace all calls to it (except in error message formatting code) with UnionType.make_union(). Union constructor already flattens nested unions, we can also make it remove exact duplicates minimize perf impact.

Akuli commented 4 years ago

Ideally there would be a test case to ensure #9169 won't happen again once the refactoring is done

97littleleaf11 commented 3 years ago

I've noticed that make_simplified_union has been modified several times since this issue opened:

We probably need to reconsider the necessity and ways to refactor make_union and make_simplified_union