-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problematic formatting: indentation change in docstring #10396
Comments
I would totally agree. What benefit does it have to justify it? |
Ah yeah, I'd suggest just disabling formatting for the docstring in this case. On a whole, it is a net positive (by far, in my opinion) for the formatter to correct docstring indentation than to disable it entirely due to special cases like (e.g.) ASCII art. You are of course welcome to file an issue with Black if you'd like. |
Oh I didn't know there was am option to disable it thanks!
https://github.com/astral-sh/ruff/blob/main/docs/formatter.md BTW: there are a few parameters missing in |
To avoid confusion..
I'm not sure it's worth enumerating all configuration options in the formatter overview but feel free to pull request anything you think would be helpful and we can discuss it there. |
Breaking information like this is not good and cane in the worst case be very confusing/misleading. Ruff already has some options that black does not, but I might open a PR on black side then. |
The ruff source code seems to try and keep indentation alignment in some cases, for example this code is formatted according to ruff: def dosctring_ascii_alignment():
"""Ascii art: [____,aaaa,bbbb]
^ ^
"""
pass
def dosctring_ascii_alignment():
"""
Ascii art: [____,aaaa,bbbb]
^^^^
""" As seen in the 2nd function, the docstring is not modified. |
black and ruff format might destroy ascii art in dosctring when re-indenting docstring lines. (so I'm not sure if this issue should be filed here or at the black project)
Example code:
result after
ruff format
(with version0.3.2
):as seen, the carets
^
are now misaligned.In my mind it would be better to not touch docstrings - but I guess there might be some reason for it?
The text was updated successfully, but these errors were encountered: