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

Semantic Highlighting issues with Type Hints for Generic Types #459

Closed
hassanselim0 opened this issue Oct 5, 2020 · 4 comments
Closed
Assignees
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@hassanselim0
Copy link

hassanselim0 commented Oct 5, 2020

Environment data

  • Language Server version: 2020.9.8
  • OS and version: Windows 10 v2004
  • Python version: Python 3.8.2

Expected behaviour

Given this function definition:

def calc(nums: List[int]):
    pass

The entire List[int] span should have the typeHint semantic modifier.

Actual behaviour

(note: I've overridden the token color for *.typeHint to red for clarity)
image
List gets the variable semantic without the typeHint modifier.

image
The square brackets don't get any semantic token or modifier.

Edit: It seems like these issues happen on class variable annotations too, not just in function argument annotations.

Code Snippet / Additional information

Related Feature Request: #335

@github-actions github-actions bot added the triage label Oct 5, 2020
@hassanselim0
Copy link
Author

Just found something that could narrow down this issue:
image
The semantic token type for all these types is class, except for Dict which is variable. So the problem could be that the typeHint modifier currently only applies to classes and not variables, even though variables can contain type objects.

@judej judej added the needs investigation Could be an issue - needs investigation label Oct 6, 2020
@github-actions github-actions bot removed the triage label Oct 6, 2020
@huguesv
Copy link
Contributor

huguesv commented Oct 6, 2020

Thanks for the report. We should be able to fix those.

@huguesv huguesv added bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels Oct 6, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.10.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020100-7-october-2020

@hassanselim0
Copy link
Author

hassanselim0 commented Oct 10, 2020

Thank you, I just updated and the problem is fixed.
The square brackets still don't get any token though, which I think means they can't get the typeHint modifier.
I'm not sure if it would be worth the effort though. My main purpose with the original feature request is to make the type hints less eye-catching and not stand out (currently trying out faded colors), to try and keep the code as readable as possible.
For me, what we have now is a good step and I would consider myself satisfied.

For reference, these are the colors customizations I'm experimenting right now with the Amethyst Dark theme:
image
(this screenshot it part of a Pydantic Data Model, a typing library that I've started using a lot in the past month)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

4 participants