MagicPython icon indicating copy to clipboard operation
MagicPython copied to clipboard

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

Open Cielquan opened this issue 5 years ago • 1 comments

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

Cielquan avatar May 06 '20 17:05 Cielquan

Workaround: the new Pylance language server adds semantic highlighting which "fixes" this: https://github.com/microsoft/pylance-release#semantic-highlighting

Cielquan avatar Dec 03 '20 17:12 Cielquan