PyCQA / pycodestyle

Simple Python style checker in one Python file

Home Page:https://pycodestyle.pycqa.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

E101 false positives due to mismatched indentation in module docstring

tushar-deepsource opened this issue · comments

If the docstring has indentation with tabs, and the code is indented with spaces (or vice versa), then E101 is raised on every single indented line of the codebase.

For example:

"""
foo bar
	(<-- tab here) some description
"""

def four_spaces_only():
    pass        # E101

def foo_bar():
    def baz():  # E101
        pass    # E101

I guess this can be fixed by not treating the indentation inside docstrings as the de-facto, rather using the first INDENT token.
Logic here:

if self.indent_char is None and line[:1] in WHITESPACE:

this is correct. the docstring should use spaces too

there's also a bunch of duplicates -- they are all tagged by the error code so please search that next time!

It is correct, but it's really bad UX imo.

I'll give you a valid usecase: someone was using tabs, then ran the codebase through black. now everything is spaces except the docstrings, and pycodestyle raises thousands issues on lines of code, even though all code is indented with 4 spaces.

still doesn't sound like a pycodestyle problem -- sounds like someone wants to run git ls-files -- '*.py' | xargs sed -i 's/\t/ /g'