VS Code 更新 Python 支持,微软为支持Pylance抛弃开源语言服务器

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"9月初,Microsoft 宣布"},{"type":"link","attrs":{"href":"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-september-2021-release\/","title":null,"type":null},"content":[{"type":"text","text":"更新"}],"marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}]},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"了 Visual Studio Code 中对 Python 的支持,并引入了 Web 浏览器中的编辑功能。该公司还将其开源的 Python 语言服务器存档,以支持闭源的 Pylance。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"11月份,微软将再次更新 Python in Visual Studio Code 扩展,而Microsoft Python 语言服务器也将随之结束生命周期。弃用后,"},{"type":"link","attrs":{"href":"https:\/\/github.com\/microsoft\/python-language-server","title":null,"type":null},"content":[{"type":"text","text":"Microsoft Python 语言服务器存储库"}],"marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}]},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"将被标记为已存档,不过开发者仍然可以在语言服务器的代码库上进行分叉和构建。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"Python 2.7 用户的 IntelliSense 支持来自"},{"type":"link","attrs":{"href":"https:\/\/github.com\/davidhalter\/jedi\/releases\/tag\/v0.17.2","title":null,"type":null},"content":[{"type":"text","text":"Jedi 0.17"}],"marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}]},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":",这也将是支持 Python 2.7 的最后一个Jedi版本。从10月份开始,微软将只支持Jedi 0.18和更高的版本,不再提供对Jedi 0.17的支持,同时放弃支持ctags和rope。"},{"type":"link","attrs":{"href":"https:\/\/github.com\/microsoft\/vscode-python\/wiki\/Limited-support-for-Python-2.7","title":null,"type":null},"content":[{"type":"text","text":"官方建议"}],"marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}]},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"是升级到 Python 3 或最好使用 Pylance 。但某些 Python 库仅存在于 2.x 版本中,这也可能是一个问题。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"语言服务器是驱动 VS Code 编辑器中特定编程语言的功能引擎,例如支持语法突出显示、代码完成和错误检测。微软第一次使用 Python 语言服务器是在 2018 年,并且将其"},{"type":"link","attrs":{"href":"https:\/\/github.com\/microsoft\/python-language-server","title":null,"type":null},"content":[{"type":"text","text":"开源"}],"marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}]},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"2020 年 6 月,微软宣布使用性能更高、功能更丰富的新 Python 语言服务器Pylance ,并最终放弃了旧语言服务器 Microsoft Python 语言服务器。此后,微软团队一直"},{"type":"link","attrs":{"href":"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-may-2021-release\/","title":null,"type":null},"content":[{"type":"text","text":"在改进"}],"marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}]},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"Pylance 和开源语言服务器"},{"type":"link","attrs":{"href":"https:\/\/github.com\/pappasam\/jedi-language-server","title":null,"type":null},"content":[{"type":"text","text":"Jedi 中的"}],"marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}]},{"type":"text","text":"语言服务器支持"},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Pylance 可利用语言服务器协议与 VS Code 进行通信。据介绍称,Pylance 是以微软的静态类型检查工具 Pyright 作为基础开发的全新的语言服务器,利用类型 stubs(.pyi 文件)和惰性类型推断来提供高性能的开发体验。Pylance 通过丰富的类型信息增强用户的 Python IntelliSense 体验,帮助用户更快、更好地编写代码。Pylance 扩展还随附了热门模块的形态存根档(Type Stub)集合,以提供快速、准确的自动完成和类型检查。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"根据统计数据,Python 扩展组件的安装量超过 4100 万,而第三方 Python 扩展组件的安装量仅 300 多万,后者使用 pyLint 或 flake8 作为 linter(均为开源)。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"Pylance 现在已经成为 Python for Visual Studio Code 的默认语言支持,微软几乎所有的用户都已切换到了该新语言服务器。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"尽管 VS Code 是免费和开源的,但与微软最初的 Python 语言服务器不同,Pylance是闭源的,这也是其不太吸引开发者的地方。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"Pylance的"},{"type":"link","attrs":{"href":"https:\/\/marketplace.visualstudio.com\/items\/ms-python.vscode-pylance\/license","title":null,"type":null},"content":[{"type":"text","text":"许可"}],"marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}]},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"声明显示,开发者只能在 Microsoft Visual Studio、Visual Studio for Mac、Visual Studio Code、Azure DevOps、Team Foundation Server 和后续 Microsoft 产品和服务(统称为,Visual Studio 产品和服务)中,来开发和测试应用程序。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"语言服务器是 VS Code 的基础。尽管Pylance 是建立在一个单独的开源项目"},{"type":"link","attrs":{"href":"https:\/\/github.com\/microsoft\/pyright","title":null,"type":null},"content":[{"type":"text","text":"Pyright 之上"}],"marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}]},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":",但这样的改变一定程度上还是破坏了编辑器的开源状态,并使社区更难修复问题和提出改进建议。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章