You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow overloading based on TypedDict structure #3618
Maybe we should support overloading based on the structure of a TypedDict. For example, this could be okay, even though it's currently considered overlapping:
fromtypingimportoverloadfrommypy_extensionsimportTypedDictA=TypedDict('A', {'x': int})
B=TypedDict('B', {'y': str})
@overloaddeff(x: A) ->int: ...
@overloaddeff(x: B) ->str: ...
deff(x): ...
a: Ab: Bf(a) # Should be intf(b) # Should be str
However, some overloads should probably still be considered invalid as they overlap, such as if two TypedDicts have the same keys and some value types overlap. Another special case to consider is non-total TypedDicts.
Activity
ilevkivskyi commentedon Jul 6, 2018
This now works on master.
Yes, but these will be disabled when #5280 lands, we have a separate issue to track this.