Skip to content

STYLE: pre-commit does not use flake8-comprehensions plugin #27724

Closed
@jschendel

Description

@jschendel

We use flake8-comprehensions as part of the CI process when linting code, and it's included in our environment.yml file, but it's not run as part of pre-commit.

For a simple example, add the following line of code to a file in the codebase:

sum([x + 1 for x in range(3)])

Then in the command line run:

git add .
pre-commit run flake8

And the pre-commit check passes.

However, running flake8 from the command line (like what is done in CI) fails due to the flake8-comprehensions plugin being included:

flake8 path/to/changed/file.py

Gives me the error:

C407 Unnecessary list comprehension - 'sum' can take a generator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Code StyleCode style, linting, code_checks

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions