-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Make deque subscriptable? #3413
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
Comments
Ironically, we used to have deque[int] until @ilevkivskyi disallowed that in #2869... |
The simplest solution is to just allow |
OK, let's allow that. Are there any others? |
Here is the full list of other things prohibited by #2869 for which replacements are proposed: list[int]
dict[int, str]
set[int]
tuple[int]
frozenset[int]
collections.defaultdict[int, str]
collections.Counter[str]
collections.ChainMap[str, str] All corresponding typing types are in 3.6.0. |
What about 3.5.0? Maybe we should allow indexing all types that don't have corresponding |
Wondering if there's been any movement on this? We've got exactly this situation where we want to subscript |
@matthchr -- I believe we solved this via the typing_extensions module, which contains backports of these kinds of types for older versions of Python 3.5 and 3.6. So in your case, you'd want to |
See #6593 for another (opposite, i.e. false negative) aspect of this issue. |
|
Mypy doesn't let you write
deque[int]
etc., but the recommended replacement (typing.Deque
) is not present in Python 3.6.0 typing:Maybe we should allow the above example since
typing.Deque
may be unavailable at runtime. Alternatively, we could modify the message to recommend using something like this:However, the above is pretty unintuitive.
TYPE_CHECKING
is not present in earlier versions oftyping
so it's not always an option, but we could perhaps recommend it.[Zulip hit this issue recently.]
The text was updated successfully, but these errors were encountered: