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

flake8 consideres only one configuration file since v5 #1660

Closed
hennjanssen opened this issue Aug 10, 2022 · 1 comment
Closed

flake8 consideres only one configuration file since v5 #1660

hennjanssen opened this issue Aug 10, 2022 · 1 comment
Labels

Comments

@hennjanssen
Copy link

how did you install flake8?

pip install flake8

unmodified output of flake8 --bug-report

{
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.10.4",
    "system": "Windows"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.7.0"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.9.1"
    },
    {
      "plugin": "pyflakes",
      "version": "2.5.0"
    }
  ],
  "version": "5.0.4"
}

describe the problem

what I expected to happen

In a "historically grown" project we have a setup.cfg as well as a .flake8, which both have some configurations for flake8.
With version 4 of flake8 both file were taken into account.

But with the upgrade to version 5, flake8 seems to ignore the .flake8-file. I went trough the changelog and the list of (un-)resolved issues, but could not find any explanation. #199 inspired me to take a look into its implementation:
flake8/src/flake8/options/config.py:

33    for candidate in ("setup.cfg", "tox.ini", ".flake8"):
34        ...
41        # only consider it a config if it contains flake8 sections
42        if "flake8" in cfg or "flake8:local-plugins" in cfg:
43             return cfg_path

Apparently, only the first configuration file in the list "setup.cfg", "tox.ini", ".flake8" is taken.

I don't know if this behaviour is desired or not and may be confirmed?

I think for my project I will take this issue as an occasion to merge the different configuration files.

sample code

MWE:

.
├── .flake8
├── setup.cfg
└── t.py

.flake8:

[flake8]
max-line-length = 88

setup.cfg:

[flake8]
extend-ignore = E203

t.py

print("Very, very, very, very, very, very, very, very, very, very, very long text")

commands ran

$ flake8 t.py
t.py:1:80: E501 line too long (83 > 79 characters)
@asottile
Copy link
Member

dupe #1630 -- also it's part of "Don't consider a config file which does not contain flake8 settings" -- you were in undefined territory before

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

No branches or pull requests

2 participants