PyCQA / flake8

flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.
https://flake8.pycqa.org
Other
3.43k stars 307 forks source link

flake8 5.0.1 no longer honoring tox.ini override configuration #1639

Closed b4ldr closed 2 years ago

b4ldr commented 2 years ago

how did you install flake8?

# flake8 installed as a dependency via tox in tox.ini
$ cat tox.ini
[tox]
minversion = 3.10.0
envlist = py{37,38,39,310}-{flake8,unit,bandit,mypy,prospector,sphinx},py3-style
skip_missing_interpreters = True

[testenv]
usedevelop = True
download = True
whitelist_externals = sed
description =
    flake8: Style consistency checker
    style: Style consistency checker
    format: Autoformat the changed files to match the style
    unit: Run unit tests
    bandit: Security-oriented static analyzer
    mypy: Static analyzer for type annotations
    prospector: Static analysis multi-tool
    sphinx: Build documentation and manpages
    py3: (Python 3)
    py37: (Python 3.7)
    py38: (Python 3.8)
    py39: (Python 3.9)
    py310: (Python 3.10)
envdir =
    prospector: {toxworkdir}/{envname}
    py3: {toxworkdir}/py3-tests
    py37-!prospector: {toxworkdir}/py37-tests
    py38-!prospector: {toxworkdir}/py38-tests
    py39-!prospector: {toxworkdir}/py39-tests
    py310-!prospector: {toxworkdir}/py310-tests
commands =
    flake8: flake8 setup.py spicerack
    style: {toxinidir}/utils/check-style.sh
    format: {toxinidir}/utils/format-code.sh
    unit: py.test --strict-markers --cov-report=term-missing --cov=spicerack spicerack/tests/unit {posargs}
    # Skip some bandit issues:
    # - assert_used (B101) in tests
    # - blacklist of 'subprocess' module (B404)
    # - use of subprocess_without_shell_equals_true (B603) to alert if shell True is used instead
    bandit: bandit -l -i -r --skip B404,B603 --exclude './spicerack/tests' ./spicerack/
    bandit: bandit -l -i -r --skip B101,B105,B106,B404 spicerack/tests
    mypy: mypy --show-error-codes spicerack/
    prospector: prospector --profile '{toxinidir}/prospector.yaml' {posargs} {toxinidir}
    sphinx: python spicerack/tests/sphinx_checker.py '{toxinidir}'
    sphinx: python setup.py build_sphinx -W -b html
    sphinx: python setup.py build_sphinx -W -b man
    # Fix missing space after bold blocks in man page: https://github.com/ribozz/sphinx-argparse/issues/80
    sphinx: sed -i='' -e 's/^\.B/.B /' '{toxinidir}/doc/build/man/cookbook.1'
deps =
    # Use install_requires and the additional extras_require[tests/prospector] from setup.py
    prospector: .[prospector]
    !prospector: .[tests]

[testenv:py3-format]

[flake8]
max-line-length = 120
statistics = True
ignore = W503
$  tox --recreate -e py39-flake8 --notest                                                
py39-flake8 recreate: /home/jbond/git/spicerack/.tox/py39-tests
py39-flake8 installdeps: .[tests]
py39-flake8 develop-inst: /home/jbond/git/spicerack
py39-flake8 installed: alabaster==0.7.12,attrs==22.1.0,Babel==2.10.3,bandit==1.7.4,black==21.12b0,boto3==1.24.42,botocore==1.27.42,cachetools==5.2.0,certifi==2022.6.15,charset-normalizer==2.1.0,click==7.1.2,ClusterShell==1.8.4,conftool==1.1.4,coverage==6.4.2,cumin==4.1.1,Deprecated==1.2.13,dnspython==2.1.0,docutils==0.17.1,elasticsearch==7.14.2,elasticsearch-curator==5.8.4,execnet==1.9.0,flake8==5.0.1,gitdb==4.0.9,GitPython==3.1.14,google-auth==2.9.1,idna==3.3,imagesize==1.4.1,importlib-metadata==4.12.0,iniconfig==1.1.1,isort==5.10.1,Jinja2==3.1.2,jmespath==1.0.1,jsonschema==4.9.0,kafka-python==2.0.2,kubernetes==12.0.1,MarkupSafe==2.1.1,mccabe==0.7.0,mypy==0.790,mypy-extensions==0.4.3,oauthlib==3.2.0,packaging==21.3,pathspec==0.9.0,pbr==5.9.0,phabricator==0.9.1,platformdirs==2.5.2,pluggy==1.0.0,py==1.11.0,pyasn1==0.4.8,pyasn1-modules==0.2.8,pycodestyle==2.9.0,pyflakes==2.5.0,Pygments==2.12.0,PyMySQL==1.0.2,pynetbox==6.6.2,pyparsing==2.4.7,pyrsistent==0.18.1,pytest==7.1.2,pytest-cov==3.0.0,pytest-forked==1.4.0,pytest-xdist==2.5.0,python-dateutil==2.8.2,python-etcd==0.4.5,pytz==2022.1,PyYAML==5.4.1,redis==4.1.3,requests==2.28.1,requests-aws4auth==1.1.2,requests-mock==1.9.3,requests-oauthlib==1.3.1,rsa==4.9,s3transfer==0.6.0,six==1.16.0,smmap==5.0.0,snowballstemmer==2.2.0,Sphinx==5.1.1,sphinx-argparse==0.3.1,sphinx-rtd-theme==1.0.0,sphinxcontrib-applehelp==1.0.2,sphinxcontrib-devhelp==1.0.2,sphinxcontrib-htmlhelp==2.0.0,sphinxcontrib-jsmath==1.0.1,sphinxcontrib-qthelp==1.0.3,sphinxcontrib-serializinghtml==1.1.5,stevedore==4.0.0,tomli==1.2.3,tqdm==4.64.0,typed-ast==1.4.3,typing-extensions==4.3.0,urllib3==1.26.4,voluptuous==0.13.1,websocket-client==1.3.3,-e git+ssh://jbond@gerrit.wikimedia.org:29418/operations/software/spicerack@ec960d7c6fb584c781dd39f3546bc0973805415d#egg=wikimedia_spicerack,wmflib==1.2.0,wrapt==1.14.1,zipp==3.8.1

unmodified output of flake8 --bug-report

{
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.9.2",
    "system": "Linux"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.7.0"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.9.0"
    },
    {
      "plugin": "pyflakes",
      "version": "2.5.0"
    }
  ],
  "version": "5.0.1"
}

describe the problem

what I expected to happen

In our tox.ini we override the line length and a few other settings and i would except theses config options to be used

what I expected to happen

the tox flake unit fails with errors about the line length

$ tox -e py39-flake8                                                                
/home/jbond/git/spicerack/.tox/py39-tests/lib/python3.9/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
  warnings.warn(
py39-flake8 develop-inst-noop: /home/jbond/git/spicerack
py39-flake8 installed: alabaster==0.7.12,attrs==22.1.0,Babel==2.10.3,bandit==1.7.4,black==21.12b0,boto3==1.24.42,botocore==1.27.42,cachetools==5.2.0,certifi==2022.6.15,charset-normalizer==2.1.0,click==7.1.2,ClusterShell==1.8.4,conftool==1.1.4,coverage==6.4.2,cumin==4.1.1,Deprecated==1.2.13,dnspython==2.1.0,docutils==0.17.1,elasticsearch==7.14.2,elasticsearch-curator==5.8.4,execnet==1.9.0,flake8==5.0.1,gitdb==4.0.9,GitPython==3.1.14,google-auth==2.9.1,idna==3.3,imagesize==1.4.1,importlib-metadata==4.12.0,iniconfig==1.1.1,isort==5.10.1,Jinja2==3.1.2,jmespath==1.0.1,jsonschema==4.9.0,kafka-python==2.0.2,kubernetes==12.0.1,MarkupSafe==2.1.1,mccabe==0.7.0,mypy==0.790,mypy-extensions==0.4.3,oauthlib==3.2.0,packaging==21.3,pathspec==0.9.0,pbr==5.9.0,phabricator==0.9.1,platformdirs==2.5.2,pluggy==1.0.0,py==1.11.0,pyasn1==0.4.8,pyasn1-modules==0.2.8,pycodestyle==2.9.0,pyflakes==2.5.0,Pygments==2.12.0,PyMySQL==1.0.2,pynetbox==6.6.2,pyparsing==2.4.7,pyrsistent==0.18.1,pytest==7.1.2,pytest-cov==3.0.0,pytest-forked==1.4.0,pytest-xdist==2.5.0,python-dateutil==2.8.2,python-etcd==0.4.5,pytz==2022.1,PyYAML==5.4.1,redis==4.1.3,requests==2.28.1,requests-aws4auth==1.1.2,requests-mock==1.9.3,requests-oauthlib==1.3.1,rsa==4.9,s3transfer==0.6.0,six==1.16.0,smmap==5.0.0,snowballstemmer==2.2.0,Sphinx==5.1.1,sphinx-argparse==0.3.1,sphinx-rtd-theme==1.0.0,sphinxcontrib-applehelp==1.0.2,sphinxcontrib-devhelp==1.0.2,sphinxcontrib-htmlhelp==2.0.0,sphinxcontrib-jsmath==1.0.1,sphinxcontrib-qthelp==1.0.3,sphinxcontrib-serializinghtml==1.1.5,stevedore==4.0.0,tomli==1.2.3,tqdm==4.64.0,typed-ast==1.4.3,typing-extensions==4.3.0,urllib3==1.26.4,voluptuous==0.13.1,websocket-client==1.3.3,-e git+ssh://jbond@gerrit.wikimedia.org:29418/operations/software/spicerack@ec960d7c6fb584c781dd39f3546bc0973805415d#egg=wikimedia_spicerack,wmflib==1.2.0,wrapt==1.14.1,zipp==3.8.1
py39-flake8 run-test-pre: PYTHONHASHSEED='4033417309'
py39-flake8 run-test: commands[0] | flake8 setup.py spicerack
setup.py:12:80: E501 line too long (81 > 79 characters)
setup.py:31:80: E501 line too long (83 > 79 characters)
setup.py:66:80: E501 line too long (85 > 79 characters)
setup.py:87:80: E501 line too long (87 > 79 characters)
b4ldr commented 2 years ago

This seems to be caused by https://github.com/PyCQA/flake8/pull/1472, previously all setup.cfg", "tox.ini", ".flake8" where considered however the code now only considers the first file it finds with a flak8 section. im unsure if this is intentional or by design. for now i have worked around the issue by moving all flak8 config to setup.cfg and dropping it from tox.ini

asottile commented 2 years ago

dupe #1630