Skip to content

Python Support v1.1.0

Choose a tag to compare

@github-actions github-actions released this 23 Nov 05:55
· 7 commits to main since this release
48cbeae

中文

  • 「设置 › 语言与框架 › Python」顶部显示当前使用的 Python 解释器,点击可打开「工具链」页更换。下面的预览卡片按尚未保存的设置画出类型检查模式、诊断范围、自动导入补全和补全函数括号的效果。

  • 「设置 › 构建、执行、部署 › 构建工具 › Python」显示 Lithe 查找解释器的顺序:项目固定的解释器和项目里的 .venv、venv、.conda,然后是全局设置,最后是自动发现;最前面标出「Python 解释器覆盖路径」是否设置,以及设置后哪些流程改用它。

  • 设置了「Python 解释器覆盖路径」时,语言页的解释器下面会说明:构建任务、运行和 pytest 用覆盖路径,Pyrefly 分析和调试仍用「工具链」页解析出的解释器。

  • 「显示类型错误」的四档现在都按标题生效。以前随包的 Pyrefly 1.4.1 只认“关闭”,其他两档和“始终开启”效果一样:

    • 始终开启:所有文件都显示,没有 Pyrefly 配置的文件按类型检查模式检查;
    • 仅已配置项目:只有 pyrefly.toml 或 [tool.pyrefly] 覆盖的文件显示;
    • 仅报告缺失导入:Pyrefly 已经没有这个模式,没有 Pyrefly 配置的文件改按“基础”检查,报告无法解析的导入和少数 Pyrefly 确定的错误;
    • 关闭:所有文件都不显示,包括有自己 Pyrefly 配置的项目。

    悬停、跳转和补全在各档都照常可用。

  • 类型检查模式新增“宽松”预设。“自动”会沿用附近的 mypy 或 Pyright 配置,没有时按“基础”检查。

  • 类型检查模式和自动导入路径风格的说明写明了它们和其他设置的关系,例如「显示类型错误」不是“始终开启”时预设怎样生效,关闭「自动导入补全」后只有代码操作会用到路径风格。

升级与兼容性

Python Support v1.1.0 要求 Lithe 0.8.9 或更新版本。从 0.8.10 开始,Lithe 还能按 shebang 自动识别无后缀脚本。已经保存的设置都继续生效。

调试需要 Python 3.10 或更新版本。内置的 debugpy 1.8.22 不支持 Python 3.9,以前在 3.9 上启动调试会直接退出、没有任何提示;现在 Lithe 会在启动调试前检查解释器版本。运行、测试和依赖树仍支持 Python 3.9。macOS 自带的 /usr/bin/python3 是 3.9,调试请在「工具链」页改用 uv、pyenv 或 python.org 安装的 Python 3.10 以上版本,或项目里用它们建的 .venv。

已知限制:在 macOS 和 Linux 上,建在项目外的虚拟环境(python -m venv、uv venv、virtualenv,以及 Poetry、Pipenv 默认建的环境)和 Homebrew 安装的 Python 暂时不能在「工具链」页选作解释器(#2316)。在此之前,可以把环境建在项目里的 .venv(Poetry 用 poetry config virtualenvs.in-project true,Pipenv 设 PIPENV_VENV_IN_PROJECT=1),或者固定 uv、pyenv、python.org 安装的解释器;只需要运行和 pytest 时,也可以把环境里的 python 填进「Python 解释器覆盖路径」。


English

  • Settings › Languages & Frameworks › Python now shows the Python interpreter in use at the top. Click it to change it on the Toolchains page. The preview cards below draw the effect of the type checking mode, diagnostic scope, auto-import completions and function parentheses, following settings you have not saved yet.

  • Settings › Build, Execution, Deployment › Build Tools › Python shows the order in which Lithe looks for an interpreter: the project's pinned interpreter and its .venv, venv or .conda, then the global setting, then automatic discovery. It first shows whether Python executable override is set, and which work uses it when it is.

  • When Python executable override is set, the language page says so under the interpreter: build tasks, runs and pytest use the override, while Pyrefly analysis and debugging still use the interpreter the Toolchains page resolves.

  • All four Display type errors choices now do what their titles say. The bundled Pyrefly 1.4.1 used to honor only Off, and the other two choices behaved like Always on:

    • Always on: every file shows type errors, and files without a Pyrefly config are checked by the type checking mode.
    • Configured projects only: only files a pyrefly.toml or [tool.pyrefly] covers show them.
    • Missing imports only: Pyrefly no longer has this mode, so files without a Pyrefly config are checked as Basic, which reports unresolved imports and a few other errors Pyrefly is sure of.
    • Off: no file shows them, including projects with their own Pyrefly config.

    Hover, go to definition and completion keep working with every choice.

  • The type checking mode has a new Legacy preset. Automatic follows a nearby mypy or Pyright config, and checks as Basic when there is none.

  • The descriptions of the type checking mode and the auto-import module path style now explain how they depend on other settings. For example, they say how the preset applies when Display type errors is not Always on, and that with Auto-import completions off only code actions use the path style.

Upgrade and compatibility

Python Support v1.1.0 requires Lithe 0.8.9 or later. Starting with 0.8.10, Lithe can also recognize extensionless scripts by their shebang. Settings you have saved keep working.

Debugging requires Python 3.10 or later. The bundled debugpy 1.8.22 does not support Python 3.9, and starting a debug session on 3.9 used to exit without any message. Lithe now checks the interpreter version before it starts debugging. Runs, tests and the dependency tree still support Python 3.9. The /usr/bin/python3 that comes with macOS is 3.9, so to debug, choose Python 3.10 or later installed by uv, pyenv or python.org on the Toolchains page, or a .venv in the project made from one.

Known limitation: on macOS and Linux, virtual environments outside the project (made by python -m venv, uv venv or virtualenv, and the environments Poetry and Pipenv create by default) and Homebrew Python cannot be chosen on the Toolchains page yet (#2316). Until then, create the environment in the project as .venv (for Poetry, poetry config virtualenvs.in-project true; for Pipenv, set PIPENV_VENV_IN_PROJECT=1), or pin an interpreter installed by uv, pyenv or python.org. If you only need runs and pytest, you can also enter the environment's python in Python executable override.

Lithe Store 会在收录后提供此版本。打开 设置 → 插件 → 插件市场,搜索 Python Support。

SHA-256

124c37e0f1da2b5515075f22761840c03d7898f878768854005e7ad705debecd  ./python-support-1.1.0-darwin-arm64.zip
8e241fc862b6b56d7ace8a510c85a9af61f13f4a31fc68c8d9a2ea3bed7e07d3  ./python-support-1.1.0-darwin-x64.zip
e45005abfd847d20e596866553b4d7429cd53838cc7891fe7bf98b3f61e00cbf  ./python-support-1.1.0-linux-arm64.zip
76cfcd365b6d6c18e6df664fdb03ecc3347092fb8ca5eee2145d8b058a8a47cc  ./python-support-1.1.0-linux-x64.zip
63b87282f17c2db6c850cf548b539e81d0b6bfddd9622bbcbc4516b637864bf6  ./python-support-1.1.0-windows-arm64.zip
d0d3181e773b7a248e9956f3bba99cf677a1fa17bdcf28dd370af6a66b5c115d  ./python-support-1.1.0-windows-x64.zip