PyCQA / PyCQA/pycodestyle

E117: False positive with tab indentation

Open
#1,013 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.2k
Forks
754
PR merge metrics
No merged PRs in 30d

Description

If anything precedes with two spaces, e.g. the indentation of a multiline string flake8 detects an E117 for the next correctly indented line (if indentation uses tabs):

TEST_STRING = '''
foo
  bar
'''

if __name__ == '__main__':
    print(TEST_STRING)  # indented with tab!
test_flake8_e117.py:7:1: E101 indentation contains mixed spaces and tabs
test_flake8_e117.py:7:2: E117 over-indented
$ python3.9 flake8 --version
3.9.2 (mccabe: 0.6.1, pycodestyle: 2.7.0, pyflakes: 2.3.1) CPython 3.9.1 on Linux

I can only reproduce this with flake8, not with raw pycodestyle.
Maybe related #885 #836 #705.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report from test_flake8_e117.py with Python 3.9, flake8 3.9.2, and the listed pycodestyle version, then compare the result with raw pycodestyle. Trace the E117 indentation handling and add coverage so the correctly indented tab line is not falsely reported, while the genuine mixed-indentation diagnostic remains.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.