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

Expand type alias for completion provider #1174

Merged
merged 4 commits into from
Nov 16, 2020

Conversation

cdce8p
Copy link
Contributor

@cdce8p cdce8p commented Nov 15, 2020

Match type alias from completion provider with hover provider. The type alias will only be expanded if the completion item is the alias itself to preserve readability.

See: microsoft/pylance-release#562

// Determine if this identifier is a type alias. If so, expand
// the type alias when printing the type information.
const type = evaluator.getType(typeNode);
let expandTypeAlias = false;
if (type && TypeBase.isInstantiable(type)) {
const typeAliasInfo = getTypeAliasInfo(type);
if (typeAliasInfo) {
if (typeAliasInfo.aliasName === typeNode.value) {
expandTypeAlias = true;
}
label = 'type alias';
}
}

Screen Shot 2020-11-16 at 00 06 32

Screen Shot 2020-11-16 at 00 08 14

@erictraut
Copy link
Collaborator

This change looks good to me, but a unit test should be added for it.

@cdce8p
Copy link
Contributor Author

cdce8p commented Nov 16, 2020

I've added a unit test

@erictraut
Copy link
Collaborator

Thanks for the contribution. Merging.

@erictraut erictraut merged commit d5bf276 into microsoft:master Nov 16, 2020
@cdce8p cdce8p deleted the expand-type-alias branch November 16, 2020 14:26
heejaechang pushed a commit to heejaechang/pyright that referenced this pull request Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants