-
Notifications
You must be signed in to change notification settings - Fork 907
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
Investigate how documentation tooling treats indents in docstrings #8445
Comments
Is there any way to suppress formatting of docstrings for now? |
You can add def func():
"""abc
def
ghi
""" # fmt: skip But there is no dedicated setting to enforce this globally (and, candidly, I think we're unlikely to add one). |
Thanks, but frankly that's just not feasible for any bigger codebase. I added some examples to #8430 to show what the current behaviour does to our codebase. That just looks wrong, regardless if E101 is activated or not. If E101 would ignore multiline strings and the formatter would use the value of |
Makes sense! I'm sure we'll make some improvements to the tab-in-docstring behavior (hence this issue). It just hasn't been prioritized yet. But I'd rather spend time fixing the root cause than investing in other workarounds. |
@konstin I don't see the same behavior as you:
Sphinx seems to be configurable using the |
(As pointed out on Discord, this behavior will be changing in Python 3.13.) |
|
I'm closing this issue. Most documentation tools use a version of |
In the formatter, we currently normalize docstring indentation in the same way as black and cpython do. For example this is what cpython does, using
str.expandtabs
with a fixed width of 8 on python 3.13:This becomes a problem when using the formatter with tab indentation, esp. with a tab width that is not 8, because we're either inconsistent with tab indentation or mismatch what cpython does. We should investigate how the various docs tools handle docstring indents. If the indent size or kind doesn't matter to them, we have more freedom in e.g. converting to tabs inside docstrings, otherwise we need to know which properties we need to preserve.
The text was updated successfully, but these errors were encountered: