Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Assessment

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

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.

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

When a type annotation is added to the self parameter the special scope for self is missing.
image

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
Dominant language
JavaScript
Stars
1.4k
Forks
98
PR merge metrics
No merged PRs in 30d

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.

More from MagicStack/MagicPython

All issues in MagicStack/MagicPython

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.