python的另一个不妥协的代码格式化程序。
straitjacket的Python项目详细描述
StraitJacket: Another Uncompromising Code Formatter for Python
紧身衣是一种黑色的包裹物,用来包裹柱子 执行自动代码对齐的处理。
项目/回购:
代码质量/ci:
Name | role | since | until |
---|---|---|---|
Manuel Barkhau (mbarkhau@gmail.com) | author/maintainer | 2018-10 | - |
Alignment
Example of automatic alignment.
^{pr 1}$Usage
Usage is exactly the same as for ^{
Editor/Tooling Integration
Plugins for your editor usually support setting a custom path to black. You can simply point to sjfmt instead.
Unix
^{pr 3}$Windows
^{pr 4}$sublack:
{"black_command":"C:/Python37/Scripts/sjfmt.exe","black_line_length":100,//...}
文档格式化可以用Ctrl+Alt+F
触发。
vscode python extension
{"python.formatting.provider":"black","python.formatting.blackPath":"C:\\Python37\\Scripts\\sjfmt.exe","python.formatting.blackArgs":["--line-length","100","--py36","--skip-string-normalization"],}
文档格式化可以用Shift+Alt+F
触发。
BlackPycharm
安装插件black-pycharm
,可以在
Settings > Plugins > Brows Repositories
。你可能不得不
重新启动pycharm以加载插件。
要配置路径,请转到Settings > Tools > BlackPycharm Configuration
,并将Path to Black executable
设置到该位置
sjfmt二进制文件的。
您可以使用Ctrl + Shift + A
重新格式化代码,以访问
Find Action
面板。格式化代码的操作的名称
是Reformat code (BLACK)
。您可能需要重新绑定此操作,
至少在我的设置中,默认绑定似乎不起作用。
薄片8
根据这个插件的性质,某些flake8代码将
违反了。这是从你可能放在
setup.cfg
忽略这些:
[flake8]
ignore =
# No whitespace after paren open "("
E201
# No whitespace before paren ")"
E202
# Whitespace before ":"
E203
# Multiple spaces before operator
E221
# Multiple spaces after operand
E222
# Multiple spaces before keyword
E272
紧身衣的变更日志
V201904.0010-β
- 更新以释放black==19.3b0
V201812.0007-α
tldr:更多错误修复和更新的文档
V201812.0006-α
tldr:没有大的变化,只是bug修复。
- 修正了1:当数字前面没有数字时,禁用数字的右对齐。
- 修正了3:当前面有多行字符串时禁用对齐。
- 修正了4:不对齐上下文中的空格过多。
- 修正了8:字符串周围的双引号和单引号不一致
V201810.0004-α
- 初始版本