Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Fix List[T] not inheriting list/List methods #260

Closed

Description

microsoft/vscode-python#2446

E.g.

from typing import List

def func(a: List[str]):
    pass

Currently a has no completions instead of having completions for a list.

See generics from PEP 484 for some details.

Activity

  1. MikhailArkhipov commented on Oct 15, 2018

    @MikhailArkhipov

    image

  2. jakebailey commented on Oct 15, 2018

    @jakebailey
    Member

    Yeah, this works for both of those two cases:

    list

  3. jakebailey commented on Oct 15, 2018

    @jakebailey
    Member

    Actually, reading through that vscode-python bug, the user is expecting to see list functions on a, not just __getitem__ and __iter__. I'm not sure if that's exactly correct, though, since I don't think the generic type assumes anything other than "I can be indexed" and "I can be iterated over".

  4. jakebailey commented on Oct 15, 2018

    @jakebailey
    Member

    Reading through that thread also shows that def func(a: List) will show completions for a as though it were list, but def func(a: List[str]) will not, which seems to indicate that there's something else going on here.

  5. jakebailey commented on Oct 15, 2018

    @jakebailey
    Member

    typing.py says:

    class List(list, MutableSequence[T], extra=list):

    Which to me implies that it should be inheriting everything from list.

  6. changed the title [-]Work with generics[/-] [+]Fix List[T] not inheriting list/List methods[/+] on Oct 15, 2018
  7. brettcannon commented on Oct 15, 2018

    @brettcannon
    MemberAuthor

    I have updated my comment to drop the a[0] case as that case works as demonstrated, but as Jake Bailey (@jakebailey) realized the a case is not working as it should be showing all completions that list would show.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions