Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude directories handled differently for flake8 diff #1434

Closed
tnh8 opened this issue Oct 22, 2021 · 2 comments
Closed

exclude directories handled differently for flake8 diff #1434

tnh8 opened this issue Oct 22, 2021 · 2 comments

Comments

@tnh8
Copy link

tnh8 commented Oct 22, 2021

Please describe how you installed Flake8

$ pip install flake8

Please provide the exact, unmodified output of flake8 --bug-report

C:\>flake8 --bug-report
{
  "dependencies": [],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.7.9",
    "system": "Windows"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "is_local": false,
      "plugin": "pycodestyle",
      "version": "2.8.0"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "2.4.0"
    }
  ],
  "version": "4.0.1"
}

Please describe the problem or feature
Running two flake8 jobs, a full scan and a diff check, only one of them respects the directories in exclude sections when written as described in the documentation examples I found 1 2.

If this is a bug report, please explain with examples (and example code) what you expected to happen and what actually happened.

I'm using the following configuration:

setup.cfg:

[flake8]
statistics = True
show-source

exclude =
    thirdParty

Then add some error in some file placed in directory named thirdParty.

Running the following job does not produce any findings:

flake8 --append-config=setup.cfg .

But running this command will find the issue:

git diff -- '*.py' | flake8 --diff  --append-config=setup.cfg -

my output:

$ git diff -- '*.py' | flake8 --diff --append-config=setup.cfg -
python/thirdParty/merge.py:95:21: W291 trailing whitespace
1     W291 trailing whitespace

Workaround:
changing the exclude section to:

exclude =
    */thirdParty/*

makes also the diff example run without any findings.

@sigmavirus24
Copy link
Member

--diff is equivalent to telling flake8 lint these files and only report errors on changed lines. --exclude is difficult here. I'm also fairly certain that --diff should disappear

@asottile
Copy link
Member

in #1389 we're planning to significantly change or remove --diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants