PyCQA / PyCQA/pycodestyle

W191: erroneously checks indentation within triple-quoted strings

Open
#376 16 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The following code

if True:
    print("""
    tab at start of this line
""")

produces

test.py:3:1: E101 indentation contains mixed spaces and tabs
test.py:3:1: W191 indentation contains tabs

Both of these are wrong, I believe, because the string content is not part of the program indentation.

python -t does not warn about this either.

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

No source file or test is named. Reproduce the example with pycodestyle and compare it with python -t; the work is done when indentation inside the triple-quoted string no longer produces E101 or W191 while program indentation is still checked.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.