partially overlapping overload with union
Description
In this case, if i pass the config as str | dict[str, object], from the overloads i was expecting it would estimate the type individually for each segment of Union, so for str it should be object and for the dict it returns as it is so the final type should be object but basedpyright is showing str | dict[str, object]
i think this is just because overload implementations are not checked to ensure that they conform to the overload signatures. #290
I don't think it has anything to do with the implementation.
str | dict[str, object] is not a str, so the first overload doesn't match.
In the second overload, T resolves to str | dict[str, object] so it just uses that overload.
I'm not sure how we would come up with consistent logic for splitting the union like that. If we always split the union, then if someone puts a union annotation in the overload, it would never match.
so you want the union type to distribute across the overloads, even if it can already find a matching overload? pyright already does this in cases where no single type in the union matches (playground), but i guess it does make more sense to just always do it, because how could a function know at runtime whether the value came from a union or not? seems like such a change would make it easier for function implementations to match what their overloads say they do.
this is a massive fail...
I feel like it's an issue with the overload validation. if you swap T with object then it breaks. but I'm not sure, I need to think about it some more
Code sample in basedpyright playground