MagicStack / MagicStack/MagicPython

Support for PEP 695 (Type parameters / generics)

Open
#262 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.4k
Forks
98
PR merge metrics
No merged PRs in 30d

Description

Related to #229: when writing a generic class/function that uses type parameters, the syntax is incorrectly highlighted. This syntax was introduced in 3.12 via [PEP 695](https://peps.python.org/pep-0695/).

Currently these are incorrectly scoped as attribute access (see attached screenshots). MVP to reproduce is simply

```python
class Foo[T]:
pass
```

* **Editor name and version**: Sublime text 4169
* **Platform**: Windows 10
* **Color scheme**: Monokai
* **MagicPython version**: 1.1.1

![2024-01-15-magicpython_pep_695](https://github.com/MagicStack/MagicPython/assets/6155386/14373e05-517f-414f-b64a-4afeab6becf4)
![2024-01-15-magicpython_pep_695_scope](https://github.com/MagicStack/MagicPython/assets/6155386/8d35ad3a-348e-4505-8794-65c3197ae07d)
![2024-01-15-magicpython_pep_695_scope_2](https://github.com/MagicStack/MagicPython/assets/6155386/64d8a977-4a8e-4351-b77a-7407f7aa7cc0)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PEP 695 examples and reproduce the issue using `class Foo[T]: pass` in a supported editor. Inspect the syntax-highlighting rules that assign attribute-access scopes to type-parameter syntax. Done means the PEP 695 forms receive appropriate scopes and the regression is covered by the project's existing tests, if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.