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
We could probably treat List[<nothing>] as a subtype of List[X] without significant unsafety if we ensure that no variables will be inferred with List[<nothing>] types, and List[<nothing>] can't be used as a declared type. This was discussed elsewhere a while ago. With this restriction, you can't easily perform mutation operations on an empty list that would also be used as a value in another context, since all values are usually temporaries. (Yes it's easy enough to construct an example where this is still unsafe, but these seem very unlikely to happen in real code).
#6572 is an example that this could be useful, but this has come up in other contexts as well.
Activity
ilevkivskyi commentedon Apr 3, 2019
This is basically what pyre does, see discussion in python/typeshed#2817
ilevkivskyi commentedon Oct 18, 2019
This may be also relevant for other empty containers that are invariant, like empty dicts, see #7727
msullivan commentedon Dec 10, 2019
If this enables fixing the
gettype in typeshed, then I think it would fix some real world precision issues: #8123ilevkivskyi commentedon Sep 27, 2023
I just merged a PR doing this, and then found this issue again.