Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Match type narrowing between tooltip and hover #593

Closed
cdce8p opened this issue Nov 11, 2020 · 4 comments
Closed

Match type narrowing between tooltip and hover #593

cdce8p opened this issue Nov 11, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@cdce8p
Copy link

cdce8p commented Nov 11, 2020

Environment data

  • Language Server version: 2020.11.0
  • OS and version: macOS
  • Python version: 3.9

Actual behaviour

The type information differs between tooltip and hover. This issue might be linked to #562.

Screen Shot 2020-11-11 at 01 07 38

Expected/Suggested behaviour

The hover box should display the narrowed type.

Code Snippet / Additional information

from __future__ import annotations
from random import random

var: int | None = 42 if random() > 0.5 else None
if isinstance(var, int):
    var
@erictraut
Copy link
Contributor

The type displayed in the completion suggestion is always the declared type whereas the hover text shows the narrowed type. This is the intended behavior.

@cdce8p
Copy link
Author

cdce8p commented Nov 11, 2020

Would it be possible or an idea to show the narrowed type as well? I for one don't usually use hover while writing and I could imaging others doing the same. Especially since the completion list does take the narrowed type into account (which is what I would expect).

The same example just with var: int | str:

Screen Shot 2020-11-11 at 01 40 28

@judej judej added the needs investigation Could be an issue - needs investigation label Nov 11, 2020
@github-actions github-actions bot removed the triage label Nov 11, 2020
@jakebailey
Copy link
Member

Look at old issues; interestingly TS has chosen to do something different here.

image

@jakebailey jakebailey added enhancement New feature or request and removed needs investigation Could be an issue - needs investigation labels Aug 31, 2021
@judej
Copy link
Contributor

judej commented Apr 20, 2022

Moving this issue to discussion as an enhancement request for comments and upvotes.

@microsoft microsoft locked and limited conversation to collaborators Apr 20, 2022
@judej judej converted this issue into discussion #2683 Apr 20, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants