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

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

Closed
brettcannon opened this issue Oct 15, 2018 · 6 comments
Closed

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

brettcannon opened this issue Oct 15, 2018 · 6 comments
Assignees
Labels
bug Something isn't working feature: intellisense
Milestone

Comments

@brettcannon
Copy link
Member

brettcannon commented Oct 15, 2018

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.

@MikhailArkhipov
Copy link

image

@jakebailey
Copy link
Member

Yeah, this works for both of those two cases:

list

@jakebailey
Copy link
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".

@jakebailey
Copy link
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.

@jakebailey
Copy link
Member

jakebailey commented Oct 15, 2018

typing.py says:

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

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

@jakebailey jakebailey changed the title Work with generics Fix List[T] not inheriting list/List methods Oct 15, 2018
@brettcannon
Copy link
Member Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working feature: intellisense
Projects
None yet
Development

No branches or pull requests

3 participants