-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make List[<nothing>] a subtype of List[X]? #6613
Labels
Comments
This is basically what pyre does, see discussion in python/typeshed#2817 |
This may be also relevant for other empty containers that are invariant, like empty dicts, see #7727 |
If this enables fixing the |
I just merged a PR doing this, and then found this issue again. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We could probably treat
List[<nothing>]
as a subtype ofList[X]
without significant unsafety if we ensure that no variables will be inferred withList[<nothing>]
types, andList[<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.
The text was updated successfully, but these errors were encountered: