-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed as not planned
Closed as not planned
Copy link
Description
A minimal code snippet that reproduces the bug.
File name: format_ruff.py
Before ruff:
class MyClass:
def __add__(self, other: int) -> int: ...After ruff:
class MyClass:
def __add__(self, other: int) -> int:
...The command you invoked
ruff format format_ruff.py Note: in real-life scenario, one might have installed the Ruff extension on VSCode, opened a file with many stubs like in the minimal code snippet, and see them all formatted, introducing unwanted code change, which can be annoying for version control.
This might also slow down ruff adoption in existing large code bases where the case mentioned above happens a lot.
The current Ruff settings
No overriden settings. I ran a pip install ruff then ran the command above
The current Ruff version
ruff --version
ruff 0.2.2What I would like
A way to opt-out of de-inlining the Ellipsis (...) in stubs. I have searched in documentation without finding such an option. I browsed the following issues (in Links section).
An option could be:
[tool.ruff.format]
keep-single-line-ellipsis = trueLinks
Related Issues:
- Formatter: Ellipses in stub files get formatted on a single line #5822 -> It seems the solution only applied to
.pyifiles, not.py; I would like the option to be activable for all types of files. - Allow reduced number of blank lines for dummy implementations psf/black#1797 (referred to in the issue above)
Related PRs:
- Format function and class definitions into a single line if its body is an ellipsis #6592 (exposes the same situation described in this issue! it seems to only apply to
.pyifiles, but maybe it could be generalized to.py?) - Use one line between top-level items if formatting a stub file #6501
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels