ISort 可以与 Ruff 格式化程序一起使用吗? (不是短绒)

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

我正在将我的项目迁移到 RUFF。迁移有点简单,但由于某种原因,当我在 VSCode 上执行此命令时,未应用 ISort 规则:

Format code with > Ruff

当我对导入进行排序时,我看到了这一点:

我可以单击

Fast fix
选项(
Ctrl+.
。抱歉,我的 VSCode 是西班牙语),它会得到修复,但当我执行 VSCode Format Code With > Ruff 时,它不会被修复。

如果您想知道,当我运行

ruff check . --fix
时,导入会得到修复。

这是我的

ruff.toml


[lint]
extend-select = [
  "E501", # Add the `line-too-long` rule to the enforced rule set.  # By default, Ruff omits rules that overlap with the use of a formatter
]
ignore = [
  "E712", # (x == True) is allowed.
  "D100", # Docstring allowed rules
  "D105",
  "D107",
  "D203",
  "D213",
]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or McCabe complexity (`C901`) by default.
# Also add ISort (`I`) rules.
select = ["E4", "E7", "E9", "F", "I"]

# Allow fix for all enabled rules (when `--fix`) is provided. (only safes fixes will be applied)
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

我可能做错了什么,因为这个 iSort 修复用于与黑色格式化程序一起使用。我在 VSCode 设置中选择了此选项。

提前致谢。

python formatter isort ruff
1个回答
0
投票

我不知道

ruff
是否在此 VS Code 命令中使用
--fix
标志执行,但我会尝试将
fix = true
包含在
ruff.toml
中。

有关详细信息,请参阅 https://docs.astral.sh/ruff/settings/#fix

© www.soinside.com 2019 - 2024. All rights reserved.