PyCQA / PyCQA/pycodestyle

Pycodestyle complains when having two blank lines between imports and classes with a comment inbetween.

Open
#652 8 comments 3 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

I use flake8 v3.3.0 which contains pycodestyle v2.3.1

This code fails:

import sys

# Some classes

class One:
    pass


class Two:
    pass


# Some other stuff

def foo():
    print(sys.path)

If I add a blank line between the import statement and the comment, flake8 runs correctly but isort fails. See https://github.com/timothycrosley/isort/issues/550.

The isort maintainer means that isort is correct according to PEP8.

See also https://gitlab.com/pycqa/flake8/issues/336 where is said that this is a pycodestyle issue.

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 reported snippet with pycodestyle 2.3.1 and compare its result with the PEP 8 interpretation described in the issue. Review the linked isort issue and flake8 issue for the expected handling of comments between imports and classes; done when the conflicting valid layout is consistently handled without introducing a regression.

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.