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

Add support for PEP 585 #229

Closed
sprt opened this issue Nov 16, 2020 · 1 comment
Closed

Add support for PEP 585 #229

sprt opened this issue Nov 16, 2020 · 1 comment
Assignees

Comments

@sprt
Copy link

sprt commented Nov 16, 2020

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).

  • Editor name and version: VS Code 1.51.1
  • Platform: Ubuntu 16.04
  • Color scheme: Tomorrow Night (also tested with other ones but none exhibit the desired behavior)
  • MagicPython version: From the VS Code extension = 1.1.0
  • A screenshot:
    Screenshot from 2020-11-16 15-29-09
  • 5-10 lines of surrounding code: None
@Cielquan
Copy link

Cielquan commented 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 and list have the scope support.type.python. This scope also applies for the int in this snippet: print(int(1.2)).

There are scopes for type hint comments though:

meta.typehint.comment.python
comment.typehint.directive.notation.python
comment.typehint.ignore.notation.python
comment.typehint.punctuation.notation.python
comment.typehint.type.notation.python
comment.typehint.variable.notation.python

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-highlighting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants