简体   繁体   English

python black formatter 可以使用制表符而不是空格吗?

[英]Can python black formatter use tabulators instead of spaces?

I want to use the python black code reformatter in my pre-commit hooks, but in my company they decided to use tabulators in python code instead of spaces.我想在我的预提交挂钩中使用python 黑色代码重新格式化,但在我的公司中,他们决定在 python 代码中使用制表符而不是空格。 So I tried to change blacks configuration, but I haven't seen any option to use tabulators, only thing you can influence in is the line length.所以我尝试更改黑色配置,但我还没有看到任何使用制表符的选项,唯一可以影响的是行长。

Is black so tightly bound to the PEP8 standard that it will never allow tabulators?黑色是否与 PEP8 标准如此紧密地绑定在一起,以至于它永远不会允许制表符?

It is not possible.这不可能。 The Python Black supports only the spaces. Python Black 仅支持空格。

Here is a ticket for it: https://github.com/psf/black/issues/47 (It contains a conversation why Python Black won't support the tabs).这是它的一张票: https : //github.com/psf/black/issues/47 (它包含一个对话为什么 Python Black 不支持选项卡)。

As they said when they closed the ticket:正如他们在关闭票证时所说:

No, tabs for indentation are the devil.不,缩进的制表符是魔鬼。 Making this configurable would go against Black's philosophy.将其设为可配置将违背 Black 的理念。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM