MagicStack / MagicStack/MagicPython

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

未关闭
#209 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
JavaScript
星标
1.4k
派生
98
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从复现的 Python 代码片段开始,使用开发者 token 检查工具检查带注解和不带注解的 self 参数的 token 作用域。跟踪处理类方法参数的语法高亮路径;当 self: Test 保留与未注解的 self 相同的特殊 self 作用域时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, python
领域
tooling
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。