PyCQA / PyCQA/pycodestyle

E131: inconsistent reporting when comment present on initial line

Open
#1,055 0 comments 0 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

This (correctly, IMO) produces no warnings:

import foo

dct = {
    'key':
        foo.yadayada() if foo.some_condition()  # raises no warnings
        else foo.blablebli()
}

On the other hand, simply adding a comment on the 'key' line makes it raise E131 on the two most indented lines:

import foo

dct = {
    'key':  # some comment added
        foo.yadayada() if foo.some_condition()  # now, this raises E131
        else foo.blablebli()
}

Using pycodestyle 2.8.0.

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. Start by reproducing both Python snippets with pycodestyle 2.8.0 and trace the E131 reporting path; done means equivalent formatting reports consistently, with regression coverage for the comment and no-comment cases.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.