pylance-release
pylance-release copied to clipboard
Syntax highlighting for PEP 695: Type Parameter Syntax
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:
Is this color intentional or have i not set up pylance correctly?
See the discussion, but it looks like we don't return a separate token for this case:
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.
Any updates ? Since we all start adopting python 12 in our projects, it gets frustrating to miss on new features...
As an update, I ended up switching from pylance to based pyright. https://marketplace.visualstudio.com/items?itemName=detachhead.basedpyright
a: MyType also shows MyType as white. we should update our semantic tokenizer to support new TypeAlias at the decl and usage.
This issue has been fixed in prerelease version 2025.1.100, which we've just released. You can find the changelog here: CHANGELOG.md
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.
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: ...
As @cdce8p said, this is still not fully working for generic class type parameters in 2025.2.1.
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.