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

Improve semantic highlighting of TypeAlias #3100

Open
xiaoxi-david opened this issue Jul 24, 2022 · 6 comments
Open

Improve semantic highlighting of TypeAlias #3100

xiaoxi-david opened this issue Jul 24, 2022 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@xiaoxi-david
Copy link

I wonder if:

  • Pylance could use TypeAlias instead of the type alias name for the type hinting for type aliases. According to PEP 613, the type hinting for type aliases should be TypeAlias.

  • Pylance could use the same color to display type hintings regardless of whether they are native or type aliases. When I use the theme Horizon Extended Theme, native type hintings are in yellow and type aliases in red (like variables).

Example:
alias_test

I am using:

  • VS Code:
    Version: 1.70.0-insider (system setup)
    Commit: 13ba7bb446a638d37ebccb1a7d74e31c32bb9790
    Date: 2022-07-22T05:17:00.353Z
    OS: Windows_NT x64 10.0.19044
  • Python extension: 2022.11.12031009
  • Pylance extension: 2022.7.41
@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Jul 25, 2022
@bschnurr bschnurr self-assigned this Jul 25, 2022
@bschnurr bschnurr added the bug Something isn't working label Jul 25, 2022
@bschnurr bschnurr removed their assignment Jan 5, 2024
@debonte debonte changed the title Improvements for type aliases Improve semantic highlighting of TypeAlias Mar 1, 2024
@debonte debonte added enhancement New feature or request and removed bug Something isn't working labels Mar 1, 2024
@debonte
Copy link
Contributor

debonte commented Mar 1, 2024

Similarly, consider behavior of NewType -- #3754

@jnooree
Copy link

jnooree commented Jun 7, 2024

Any updates on this?

@rchiodo
Copy link
Contributor

rchiodo commented Jun 7, 2024

Sorry but this is not currently planned. However you can get this somewhat by yourself.

The TypeAlias is flagged with a typehint modifier in the semantic token. This allows you to override the color:

image

    "editor.semanticTokenColorCustomizations": {
        "[Default Dark Modern]": {
            "rules": {
                "*.typeHint": "#4EC9B0"
            }
        }
    }

Which for me, gives the same color for the typehint as the original type.

image

@jnooree
Copy link

jnooree commented Jun 7, 2024

Great, I'll try for it. Thanks!

@jnooree
Copy link

jnooree commented Jun 7, 2024

It works for type hints only, so I think pylance should still provide separate semantic tokes for type aliases (or mark them as types or classes at least).

Anyway, the type hint trick is better than nothing, thanks for the suggestion.

@Isuxiz
Copy link

Isuxiz commented Sep 29, 2024

Really need this feature!

@debonte debonte self-assigned this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants