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

Excluding dot-files/folders also excludes current directory '.' #360

Closed
asottile opened this issue Apr 3, 2021 · 8 comments
Closed

Excluding dot-files/folders also excludes current directory '.' #360

asottile opened this issue Apr 3, 2021 · 8 comments

Comments

@asottile
Copy link
Member

asottile commented Apr 3, 2021

In GitLab by @philipp.eib on May 4, 2020, 02:45

Installed with pip install --user flake8

unmodified output of flake8 --bug-report
{
  "dependencies": [
    {
      "dependency": "entrypoints",
      "version": "0.3"
    }
  ],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.8.2",
    "system": "Windows"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "flake8-bugbear",
      "version": "20.1.4"
    },
    {
      "is_local": false,
      "plugin": "flake8-docstrings",
      "version": "1.5.0, pydocstyle: 5.0.2"
    },
    {
      "is_local": false,
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "is_local": false,
      "plugin": "naming",
      "version": "0.10.0"
    },
    {
      "is_local": false,
      "plugin": "pycodestyle",
      "version": "2.5.0"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "2.1.1"
    }
  ],
  "version": "3.7.9"
}

I've tried to exclude all directories starting with a . from the checks.

When calling flake8 --exclude=.* in the project root, however, flake8 does no checks at all.
Checking the verbose debug logging following line appears

flake8.checker            MainProcess   1967 DEBUG    "." has been excluded

It seems that the implicit "current directory" . is excluded because of the .* pattern.

Calling flake8 like this flake8 --exclude=.* ../<project_root> works, however, although also technically starting with a . (it seems .. is already special-cased?)

In summary, the exclude pattern should not exclude the current directory .

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @philipp.eib on May 4, 2020, 02:46

changed the description

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @philipp.eib on May 4, 2020, 02:58

Just found out that in my case I can fix it with a trailing /

flake8 --exclude=.*/

If you think the point raised originally still holds, feel free to keep the issue open.

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @asottile on May 4, 2020, 12:58

definitely agree that this is a bug, probably needs an exclusion for . and also .. it seems

would you like to work on this? I think the necessary code is in utils.py and you'd just write a quick test for it in the corresponding test file

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @asottile on May 7, 2020, 12:35

mentioned in merge request !424

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @asottile on May 7, 2020, 12:36

I decided to fix this in !424 -- let me know what you think and if this fixes your problem

I special cased . and .. such that they are not matched against the exclusion patterns

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @asottile on May 7, 2020, 12:38

closed via merge request !424

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @asottile on May 7, 2020, 12:38

mentioned in commit 03c7dd3

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @philipp.eib on May 10, 2020, 01:33

Sorry for not getting back to you, I was pretty swamped last week.

I have tried the latest master and the problem seems fixed, thanks 👍

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

No branches or pull requests

1 participant