PyCQA / PyCQA/pycodestyle

Relax E127 with dictionary values: allow extra indent

Open
#785 1 comment 1 reaction 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

Currently pycodestyle will complain about the following:

mydict = {12345:
              'foo'}

t-61.py:2:15: E127 continuation line over-indented for visual indent

We are about to change this in https://github.com/Vimjas/vim-python-pep8-indent/pull/61, and there has been some discussion in https://github.com/python/peps/pull/113 - resulting in keeping this out of PEP8 itself (i.e. undefined).

I think pycodestyle should handle this in a relaxed way, and allow for an extra indentation level for dictionary values (after : on the previous line).

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 locating pycodestyle's E127 handling and the tests covering continuation indentation. Reproduce the dictionary example, then add coverage for the allowed extra indentation while preserving existing E127 checks. Done means the example no longer reports E127 and unrelated over-indentation cases still do.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.