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

.flake8 file ignored if tox.ini also present

Open OmeGak opened this issue 6 years ago • 5 comments

I have the "Project config file" field configured left as default, so:

Default: tox.ini, .flake8, setup.cfg

I have both a tox.ini and a .flake8 file in the root directory of my project. I don't have a [flake8] entry in the tox.ini file as my configuration for Flake8 lives in the .flake8 file. Yet, linter-flake8 seems to ignore the .flake8 file altogether since a tox.ini file is found first.

The easy solution is to manually reorder the files to be checked for flake8 configuration, but I think the default behavior should be either:

  1. To first check for the .flake8 file since it can only be used for the purpose of configuring flake8 instead of checking for the tox.ini file that is multipurpose.
  2. To keep checking for flake8 config files if the [flake8] is missing in a tox.ini file.

Opinions before I propose a PR? Is there anything I'm missing?

OmeGak avatar Dec 17 '17 11:12 OmeGak

I've just started getting the same issue too. The plugin is ignoring my setup.cfg file.

danpalmer avatar Dec 19 '17 17:12 danpalmer

I believe that order was chosen from the flake8 documentation, but looking at it now it has a different order... and then yet another different order so I'm not sure what order flake8 uses as the real search order.

Since flake8 apparently can't make up their own mind, I'd definitely be fine with searching for .flake8 first. Searching for a [flake8] section is a slightly more complex task, but as long as the results are cached if you want to implement it go for it 😉.


@danpalmer Unless you changed the setting so it isn't searching for that name, it should be working.

Arcanemagus avatar Dec 20 '17 17:12 Arcanemagus

I think we should change the default value of projectConfigFile to an empty string/none.

We execute the linter using the project's root as cwd. so Flake8 already look for a configuration file there. But projectConfigFile has default values, so if one of the default files exist then it will be passed to Flake8 with the argument --config even if it does not have a [flake8] section. When a file is passed to Flake8 using the --config then Flake8 ignores all other configuration files.

Maybe we should default it to empty? That way we let Flake8 to decide which config file to use unless we explicitly change the value of projectConfigFile to always use a specific config file.

lucasdf avatar Dec 28 '17 14:12 lucasdf

I agree with @lucasdf that the correct solution would be defaulting projectConfigFile to empty value and letting Flake8 do the right thing. On this, the problem is with Flake8 itself, that stops searching for a valid config file as soon as tox.ini or setup.cfg files are found. The issue is already reported upstream.

In the meantime, my PR is setting a reasonably sane default for linter-flake8.

OmeGak avatar Dec 28 '17 16:12 OmeGak

Actually, I cannot reproduce that issue in Flake8. Having empty string/none as the default makes Flake8 successfully handle coexisting tox.ini, setup.cfg, and .flake8 files.

OmeGak avatar Dec 28 '17 18:12 OmeGak