Skip to content
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

No entry Deque in typing.py #73197

Closed
rhettinger opened this issue Dec 19, 2016 · 4 comments
Closed

No entry Deque in typing.py #73197

rhettinger opened this issue Dec 19, 2016 · 4 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@rhettinger
Copy link
Contributor

BPO 29011
Nosy @gvanrossum, @rhettinger, @ned-deily, @ilevkivskyi
Files
  • Deque.diff: Patch to add Deque
  • Deque2.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-01-17.06:44:44.908>
    created_at = <Date 2016-12-19.06:19:33.267>
    labels = ['3.7', 'type-feature', 'library']
    title = 'No entry Deque in typing.py'
    updated_at = <Date 2017-01-17.06:44:44.907>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2017-01-17.06:44:44.907>
    actor = 'rhettinger'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-01-17.06:44:44.908>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2016-12-19.06:19:33.267>
    creator = 'rhettinger'
    dependencies = []
    files = ['45979', '46052']
    hgrepos = []
    issue_num = 29011
    keywords = ['patch']
    message_count = 4.0
    messages = ['283590', '283591', '283660', '285616']
    nosy_count = 5.0
    nosy_names = ['gvanrossum', 'rhettinger', 'ned.deily', 'python-dev', 'levkivskyi']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue29011'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @rhettinger
    Copy link
    Contributor Author

    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]]

    @rhettinger
    Copy link
    Contributor Author

    FWIW, I tried "d = deque() # type: typing.MutableSequence" but this gave:

    error: MutableSequence[Post] has no attribute "appendleft"
    

    @rhettinger rhettinger changed the title No entry for deques in typing No entry Deque in typing.py Dec 19, 2016
    @gvanrossum
    Copy link
    Member

    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).

    @rhettinger rhettinger added stdlib Python modules in the Lib dir 3.7 (EOL) end of life type-feature A feature request or enhancement labels Dec 21, 2016
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 17, 2017

    New changeset dfefbf6f6c73 by Raymond Hettinger in branch '3.5':
    Issue bpo-29011: Fix an important omission by adding Deque to the typing module.
    https://hg.python.org/cpython/rev/dfefbf6f6c73

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants