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

shell_complete's type annotation and usage don't match #1865

Closed
muggenhor opened this issue May 3, 2021 · 0 comments · Fixed by #1866
Closed

shell_complete's type annotation and usage don't match #1865

muggenhor opened this issue May 3, 2021 · 0 comments · Fixed by #1866

Comments

@muggenhor
Copy link

The declared signature of shell_complete does not match the way it is used:

Specifically it's return type is declared as List[Union[CompletionItem, str]]. This means a list where any item can be either a CompletionItem or str instance.

Instead the code that uses it tests the type of the first member of this list and assumes every other member of the list has the same type. So either the usage is wrong or the type annotation is wrong.

I.e. either the usage should be something akin to:

            results = [(CompletionItem(c) if isinstance(c, str) else c) for c in results]

Or the type annotation should have t.Union[t.List["CompletionItem"], t.List[str]] as its return type. I.e. the union should be on the outside, not the inside of the list.

FYI the type annotation was introduced by #1856 (0103c95), while the (current) code that converts to a list of CompletionItems was introduced by #1622 (3faede8).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant