MagicStack / MagicStack/MagicPython

[Bug] Class method 'self' looses special self scope with added type annotation

Open
#209 1 comment 0 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

Got send here from 'vscode-python' https://github.com/microsoft/vscode-python/issues/11593

* **Editor name and version**: VS Code version: 1.44.2
* **Platform**: Windows_NT x64 10.0.17134
* **Color scheme**: Custom (close to Monokai)
* **MagicPython version**: Dunno which vscode uses

Without type annotation everything is just fine.
![image](https://user-images.githubusercontent.com/43916661/81209538-fa16f700-8fd0-11ea-80c4-73b9e1b86bd8.png)

When a type annotation is added to the `self` parameter the special scope for `self` is missing.
![image](https://user-images.githubusercontent.com/43916661/81209597-0602b900-8fd1-11ea-92b1-0444b29f0643.png)

## Steps to reproduce:

Paste the following code into a *.py file and inspect the `self` parameter with the developer token inspect tool. Like in the screenshots above.
The `self` parameter of the `bad_func` should show the actual scopes and the `self` parameter of the `good_func` should show the expected scopes.
```
class Test:
def bad_func(self: Test):
pass

def good_func(self):
pass
```

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 reproduced Python snippet and inspect the token scopes for the annotated and unannotated self parameters using the developer token inspect tool. Trace the syntax-highlighting path that handles class method parameters; done means self: Test retains the same special self scopes as unannotated self.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.