Repository navigation
Fix overload handling with union types in signatures - #3300
Conversation
Previously `None` was not considered as more precise than `Optional[x]`, which was obviously incorrect. Fixed the implementation of type precision checking to match the description, how that proper subtype checking works. Fixes the original example in #3295.
| return is_proper_subtype(t.fallback, s) | ||
| return is_proper_subtype(t, s) | ||
| return sametypes.is_same_type(t, s) | ||
| return is_proper_subtype(t, s) |
There was a problem hiding this comment.
Why do we need a special case when t is CallableType and s is Instance? It looks like ProperSubtypeVisitor above does exactly the same. So that the whole function boils down to:
if isinstance(s, AnyType):
return True
return is_proper_subtype(t, s)There was a problem hiding this comment.
Good point. I puzzled over this for a while and it really doesn't help that the visitor uses left/right while this function uses t/s.
|
I had a similar testcase based on #3295 which still gives an error: With |
|
@JukkaL This seems stalled waiting for action/response on your end. |
|
@JukkaL, ping? |
|
This PR only addresses the first example in #3295. The more general issue requires a much more involved fix, and I think that it can be fixed in a separate PR. |
ilevkivskyi
left a comment
There was a problem hiding this comment.
This is fine for me as a quick fix. A broader solution for #3295 can be in a separate PR
|
Don't merge yet -- I'll check this with Dropbox internal codebases first. |
|
This doesn't work quite right when run against Dropbox internal codebases. I won't merge this until I've resolved the issue. |
Previously
Nonewas not considered as more precise thanOptional[x], which was obviously incorrect. Fixed theimplementation of type precision checking to match the
description, now that proper subtype checking works.
Fixes the original example in #3295.