Skip to content

Dict, List and Set are imported by default #999

Closed

Description

@gvanrossum

This code (no import from typing) complains, as expected:

a = None  # type: Any

However, this code passes:

a = None  # type: Dict

Similar with List, Set.

Activity

  1. JukkaL commented on Nov 25, 2015

    @JukkaL
    Collaborator

    Ah, seems like a problem with how mypy handles generic type aliases, such as Dict -> dict. Not sure exactly why this happens, but my guess is that they leak from builtins.pyi somehow.

  2. gvanrossum commented on Feb 22, 2016

    @gvanrossum
    MemberAuthor

    FWIW the same thing happens to Set. I don't believe there are other types that have this issue; those three (List, Dict, Set) are treated special by mypy. See https://github.com/python/mypy/blob/master/mypy/nodes.py#L74

  3. added this to the milestone on Mar 2, 2016
  4. changed the title [-]Dict and List seem to be assumed by default[/-] [+]Dict, List and Set are imported by default[/+] on Mar 15, 2016
  5. gvanrossum commented on Apr 14, 2016

    @gvanrossum
    MemberAuthor

    This is a bit thorny to fix, because Dict/List/Set are currently implemented as aliases to dict/list/set, and all the genericity is specified in typeshed/*/builtins.pyi.

    I propose not to worry too much about it for 0.3.2.

  6. JukkaL commented on Apr 14, 2016

    @JukkaL
    Collaborator

    Agreed. Maybe move this to 0.3.3?

  7. modified the milestones: , on Apr 14, 2016
  8. gvanrossum commented on Apr 14, 2016

    @gvanrossum
    MemberAuthor

    Moved to 0.3.3.

  9. added a commit that references this issue on Feb 14, 2017
    f576e84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions