-
Notifications
You must be signed in to change notification settings - Fork 94
Not planned
Description
Since PEP 585 implemented in Python 3.9, one can use the generics syntax even with built-in collections, not just those included in typing
(e.g. list
vs. typing.List
).
As such, in the screenshot below, the type hint for argument c
isn't highlighted properly. In list[int]
, both list
and int
should be highlighted, whereas only int
is highlighted currently. The type hint for argument b
is highlighted correctly (and same for a
).
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Cielquan commentedon Dec 3, 2020
Unfortunately there is no scope for inline type hints at all - as far as I could find.
The yellow highlighting in your screenshot is because
int
andlist
have the scopesupport.type.python
. This scope also applies for theint
in this snippet:print(int(1.2))
.There are scopes for type hint comments though:
I would love to see one or multiple scope(s) for inline type hints (variables, parameters, returns) like PyCharm has.
EDIT: with the new
Pylance
language server you can get semantic highlighting including type hints: https://github.com/microsoft/pylance-release#semantic-highlightingasottile commentedon Mar 12, 2025
wasn't too bad, one line change in #271 to support this