Issue 29011: No entry Deque in typing.py (original) (raw)

Issue29011

Created on 2016-12-19 06:19 by rhettinger, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Deque.diff rhettinger,2016-12-21 06:36 Patch to add Deque review
Deque2.diff rhettinger,2016-12-27 10:24 review
Messages (4)
msg283590 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-12-19 06:19
We have: # Concrete collection types. 'Dict', 'DefaultDict', 'List', 'Set', 'FrozenSet', 'NamedTuple', # Not really a type. 'Generator', But no mention of Deque. What this an intended omission? I would like to be able to write something like this: user_posts = defaultdict(deque) # type: DefaultDict[User, Deque[Post]]
msg283591 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-12-19 06:36
FWIW, I tried "d = deque() # type: typing.MutableSequence" but this gave: error: MutableSequence[Post] has no attribute "appendleft"
msg283660 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2016-12-20 00:55
I don't recall exactly what happened here, but I think it was left out during formulation of PEP 484 because it's not an ABC. IIRC originally we only wanted to include builtins and ABCs. But we changed that subsequently to include e.g. DefaultDict. I suppose we should change this now, but the cat is out of the bag for 3.6.0 and I would prefer not to change typing.py in any way between 3.6.0 and 3.5.3, so the best we could do would be to add it to 3.6.1 and 3.5.4 (whenever that will be). In the meantime collections.deque is generic, but that's only helpful in type comments, not in annotations. In a sense I wish we hadn't put typing.py in the stdlib, it would have been much simpler to fix this kind of issue. OTOH there are also advantages to having it in the stdlib, and anyways, it's too late to change, so we'll just have to suck it up (I certainly am).
msg285616 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2017-01-17 06:44
New changeset dfefbf6f6c73 by Raymond Hettinger in branch '3.5': Issue #29011: Fix an important omission by adding Deque to the typing module. https://hg.python.org/cpython/rev/dfefbf6f6c73
History
Date User Action Args
2022-04-11 14:58:40 admin set github: 73197
2017-01-17 06:44:44 rhettinger set status: open -> closedresolution: fixed
2017-01-17 06:44:23 python-dev set nosy: + python-devmessages: +
2016-12-27 10:24:22 rhettinger set files: + Deque2.diff
2016-12-22 22:53:30 levkivskyi set nosy: + levkivskyi
2016-12-21 06:36:24 rhettinger set files: + Deque.diffcomponents: + Library (Lib)versions: + Python 3.5, Python 3.6, Python 3.7keywords: + patchnosy: + ned.deilytype: enhancementstage: patch review
2016-12-20 00:55:55 gvanrossum set messages: +
2016-12-19 07:50:25 rhettinger set title: No entry for deques in typing -> No entry Deque in typing.py
2016-12-19 06:36:08 rhettinger set messages: +
2016-12-19 06:19:33 rhettinger create