I’m using ruff
as a replacement to black
formatter but I wanna keep the diff at minimum. I’m noticing that it automatically inserts a newline between the module-level docstring and the first import statement.
For example, given this code:
"""base api extension."""
import abc
from typing import List, Optional, Type
After running:
ruff format file.py --diff
It gives me this:
@@ -1,4 +1,5 @@
"""base api extension."""
+
import abc
from typing import List, Optional, Type
If I format the file, the output is like this:
"""base api extension."""
import abc
from typing import List, Optional, Type
I wanna keep the original formatting without adding that newline. I couldn’t find any settings I could use to ignore this. Is there a way to configure ruff to prevent this behaviour? Thank you!
My pyproject.toml
before adding ruff:
[tool.black]
line_length = 120
include = '.py$'
[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
line_length = 120
profile = "black"
After adding ruff
:
[tool.ruff]
line-length = 120
Context:
Python: 3.11.9
Ruff Version: 0.5.7
1