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.

Assessment

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

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.

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.

Dominant language
Python
Stars
5.2k
Forks
765
Avg merge
1d 20h
Merged PRs (30d)
1

Getting set up

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.

More from PyCQA/pycodestyle

All issues in PyCQA/pycodestyle

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.