pycharm/vscode 配置black和isort

Pycharm blackd

Pycharm中有插件可以实现后台服务运行black:BlackConnect

安装

配置

Pycharm isort

pycharm中,isort没有插件,暂使用外部工具实现,外部工具也可添加快捷键实现快捷对文件、文件夹进行format import;

shell 复制代码
isort
/xxxx/isort.exe
$/FileRelativePath$ -l 120 -m VERTICAL_HANGING_INDENT
$ProjectFileDir$

VS Code black、isort

微软均以适配,新版本的配置方式和旧版有些区别;我使用的时1.81.+。

需要安装black formater、isort插件,具体配置也可查看插件文档。

js 复制代码
"editor.formatOnSave": true, // 保存文件时格式化
// black isort
"[python]": {
    "editor.defaultFormatter": "ms-python.black-formatter",
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
        "source.organizeImports": true // isort
    },
},
"black-formatter.args": [
    // "--skip-string-normalization", // 跳过引号格式化
    "--line-length=120", // 每行字符数
],
"isort.check": true, // isort
相关推荐
bkspiderx1 天前
在Visual Studio中安装与配置Qt插件(Qt Visual Studio Tools)
ide·qt·visual studio·qt插件
lusklusklusk2 天前
使用Visual Studio一步步创建并部署SSRS_PBIRS报表:数据源配置、图表设计、参数化查询、部署参数与排错实战
数据库·ide·visual studio
解道Jdon2 天前
Rust重写OpenCode Rune:性能提升最高100倍
ide·windows·git·svn·eclipse·github·visual studio
莫卢俊德2 天前
vscode ssh config
ide·vscode·ssh
郝学胜-神的一滴4 天前
Effective Python 条款44:善用属性注解
开发语言·c++·vscode·python·算法·stl
郝学胜-神的一滴6 天前
Effective Python 条款41:试Mix‑In组合式开发
开发语言·pytorch·python·pycharm·numpy
BD_Marathon7 天前
安装Jupyter notebook
ide·python·jupyter
2601_967980117 天前
Python 办公自动化合集 ⑰:Excel自动计算——总和/平均分/最大值
python·pycharm·办公自动化·数据处理·excel自动计算
承渊政道7 天前
【Python编程快速上手—让繁琐工作自动化】(模式匹配与正则表达式:从找到一个号码到批量提取信息)
python·正则表达式·pycharm·自动化·模式匹配
讓丄帝愛伱8 天前
Zed Markdown 预览不能铺满全屏的原因及解决
ide