pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Syntax highlighting for PEP 695: Type Parameter Syntax

Open rchiodo opened this issue 1 year ago • 5 comments

Discussed in https://github.com/microsoft/pylance-release/discussions/5540

Originally posted by einarwar February 28, 2024 I recently started using python 3.12, but to my surprise the syntax highlighting for the new type parameter added in PEP 695 was white! Generally white color is used when accessing attributes/methods on Unknown objects. See image below:

image

Is this color intentional or have i not set up pylance correctly?

rchiodo avatar Feb 28 '24 21:02 rchiodo

See the discussion, but it looks like we don't return a separate token for this case:

image

rchiodo avatar Feb 28 '24 21:02 rchiodo

https://github.com/microsoft/pylance-release/issues/4645#issuecomment-1813073964

Since then I've been using this theme, which seems to have resolved the symptom described here.

dangotbanned avatar Mar 09 '24 11:03 dangotbanned

Any updates ? Since we all start adopting python 12 in our projects, it gets frustrating to miss on new features...

agalazis avatar Sep 13 '24 14:09 agalazis

As an update, I ended up switching from pylance to based pyright. https://marketplace.visualstudio.com/items?itemName=detachhead.basedpyright

agalazis avatar Sep 14 '24 11:09 agalazis

a: MyType also shows MyType as white. we should update our semantic tokenizer to support new TypeAlias at the decl and usage.

heejaechang avatar Sep 19 '24 18:09 heejaechang

This issue has been fixed in prerelease version 2025.1.100, which we've just released. You can find the changelog here: CHANGELOG.md

heejaechang avatar Jan 16 '25 20:01 heejaechang

This issue has been fixed in prerelease version 2025.1.100, which we've just released.

Awesome to have syntax highlighting for PEP 695 type aliases. However, type parameter are still missing unfortunately.

Image

Example code
from typing import Generic, TypeVar

T = TypeVar("T")

class X(Generic[T]):
    def __init__(self, var: T) -> None: ...


class Y[T]:
    def __init__(self, var: T) -> None: ...

cdce8p avatar Jan 16 '25 20:01 cdce8p

As @cdce8p said, this is still not fully working for generic class type parameters in 2025.2.1.

kamzil avatar Feb 13 '25 15:02 kamzil

Awesome to have syntax highlighting for PEP 695 type aliases. However, type parameter are still missing unfortunately.

Thanks for pointing that out. I opened https://github.com/microsoft/pylance-release/issues/6942 to track that.

debonte avatar Feb 13 '25 20:02 debonte