- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.6k
 
Description
If I have indent-style set to "tab", when I run ruff format it is still converting indentation within docstring comments to be spaces, which then causes ruff check to fail on rule E101: Indentation contains mixed spaces and tabs
Before:
After:
Is there a format setting I can add to fix this? or is this a bug/intentional?
Originally posted by @1024Adam in #7310 (comment)
We can reproduce this behavior in our own tests:
ruff/crates/ruff_python_formatter/tests/snapshots/[email protected]
Lines 538 to 544 in 3076d76
| def multiple_negatively_indented_docstring_lines(): | |
| """a | |
| b | |
| c | |
| d | |
| e | |
| """ | 
ruff/crates/ruff_python_formatter/tests/snapshots/[email protected]
Lines 569 to 577 in 3076d76
| class IndentMeSome: | |
| def doc_string_without_linebreak_after_colon(self): | |
| """This is somewhat strange | |
| a | |
| b | |
| We format this a is the docstring had started properly indented on the next | |
| line if the target indentation. This may we incorrect since source and target | |
| indentation can be incorrect, but this is also an edge case. | |
| """ | 
E101 has no special handling for docstring. It simply looks at every line and tests if the leading whitespace contains mixed spaces and tabs. Meaning, there can also be false positives if a multiline string contains leading whitespace that is a mix of spaces and tabs.

