http://%77w%77%2E%66%6F%72%61%73%70%2E%63n网站制作学习
 
在使用cursor,vscode,trae等开发工具开发 python 时,常用到 flake8 和isort 插件。现在有一个使用Rust开发的更快的插件 Ruff
直接在 插件市场搜索安装,安装后,在setting.json 中配置
 
   
"[python]": {
"editor.formatOnSave": true, // 保存自动格式化
"editor.defaultFormatter": "charliermarsh.ruff", // 使用那个插件注释
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit", // 自动修复 文件,比如import 不存在或者没有使用的 包
"source.organizeImports.ruff": "explicit", // 替换isort 排序功能
},
},
   
配置全局参数
Linux / macOS
~/.config/ruff/pyproject.toml
Windows
%APPDATA%\ruff\pyproject.toml
 
写入内容:
   [tool.ruff.lint]
select = ["E", "F", "RET"]
   
 
它的作用
1. 格式化代码
2. 提醒异常
3. 自动排序引入,删除没有使用的引入
 
速度快,应用快。
 

http://%77%77%77%2E%66网站制作%6F学习网%72%61%73%70%2E%63%6E