如何让ruff在测量线长时忽略注释?

问题描述 投票:0回答:1

线路

demo_code = print("foo bar")  # some comments and this line length exceed 79 that i config.

正在由

ruff format
格式化为

demo_code = print(
    "foo bar"
)  # some comments and this line length exceed 79 that i config.

因为它超过了

line-length
中定义的值。

我想让

ruff
只计算命令字符并忽略注释。

python ruff
1个回答
0
投票

截至 2024 年 9 月,Ruff 不支持忽略行长度规则内的注释 (

E501
)。 以下问题(以及相关问题这里这里)正在跟踪将
flake8-length
添加到ruff中,这将为此提供支持。

同时,您可以考虑禁用规则,让格式化程序自动分解比您配置的行长度更长的行,而不用担心异常。为此,请修改您的

pyproject.toml
以包括:

[tool.ruff.lint]
ignore = ["E501"]
© www.soinside.com 2019 - 2024. All rights reserved.