linter-flake8 icon indicating copy to clipboard operation
linter-flake8 copied to clipboard

Files not being excluded via Atom, but command line flake8 does

Open nogurenn opened this issue 7 years ago • 8 comments

This is the setup.cfg file. I know that the linter reads the file because ignore is honored so there's something going on with the exclude. The first screenshot shows the linter raising an error in apollo/config/settings/local.py while the second screenshot clearly shows that this file was ignored. Let me know what additional info is needed.

Using Mac OS, virtualenvwrapper

[flake8]
ignore = D100, D210, D400, D413
exclude =
    .git,
    __pycache__,
    __init__.py,
    */migrations/*,
    apollo/config/settings/*.py,
    apollo/manage.py
max-line-length = 99
max-complexity = 10

Location of flake8: ~/Developer/.virtualenvs/apollo/bin/flake8

Project structure

.
├── apollo
│   ├── config
│   │   ├── __init__.py
│   │   ├── settings
│   │   │   ├── __init__.py
│   │   │   ├── base.py
│   │   │   ├── local.py
│   │   │   ├── production.py
│   │   │   ├── settings.py
│   │   │   ├── staging.py
│   │   │   └── test.py
│   │   ├── urls.py
│   │   └── wsgi.py
│   └── manage.py
└── setup.cfg

Screenshots screen shot 2017-06-01 at 7 02 18 pm screen shot 2017-06-01 at 7 02 02 pm

nogurenn avatar Jun 01 '17 10:06 nogurenn

I was going to comment that flake8 has no method of specifying the file name for stdin content, but apparently it does as of v3.0 so this might be possible to fix now.

Arcanemagus avatar Jun 02 '17 15:06 Arcanemagus

Ping on this?

danpalmer avatar Dec 06 '17 16:12 danpalmer

v2.3.0 should fix this, let us know if it doesn't 😉.

Arcanemagus avatar Dec 06 '17 18:12 Arcanemagus

@Arcanemagus I'm on 2.3.0 and still seeing this issue.

danpalmer avatar Dec 12 '17 11:12 danpalmer

I am looking into this.

lucasdf avatar Dec 12 '17 21:12 lucasdf

Currently, the linter executes Flake8 inside of the project's root directory and it expects the configuration file to be located there. By project's root, I mean the topmost directory of the project according to Atom.

In the example provided by the OP, the files are correctly ignored. However, in any other situation where the configuration file is not in the project's root, Flake8 does not recognize the file.

@Arcanemagus I am not sure what the best approach would be. How the other linters solve this kind of issue? Should we try to locate the nearest configuration file and execute Flake8 inside that directory?

lucasdf avatar Dec 16 '17 13:12 lucasdf

@lucasdf I can reproduce this with my config in the root of my project. I use a setup.cfg file as most Python tooling supports reading it.

danpalmer avatar Dec 17 '17 23:12 danpalmer

However, in any other situation where the configuration file is not in the project's root, Flake8 does not recognize the file.

@lucasdf Ideally these providers should be "the same as running the tool in the CLI", unfortunately what that actually means can get really tricky. I generally follow the rules of:

  • "if you are in the directory of the file and run the CLI tool, the provider should match that"
  • "if you are in the project root (as seen by Atom) and run the CLI tool, the provider should match that"

Which one of those a provider falls under is just the start of the trickiness 😉.

I think this provider should follow the second one, unless this issue is describing a situation where that doesn't match what running flake8 in the CLI does, in which case we may need to change it?

Arcanemagus avatar Dec 22 '17 18:12 Arcanemagus