Skip to content

Flake8 does not find user config as documentation claims (4.0+ docs are wrong) #1435

@justin-f-perez

Description

@justin-f-perez

Please describe how you installed Flake8

$ pipx install flake8
# but it doesnt matter; docs are wrong

Please provide the exact, unmodified output of flake8 --bug-report

N/A (docs are wrong) but here it is anyway

{
  "dependencies": [],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.9.7",
    "system": "Darwin"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "is_local": false,
      "plugin": "pycodestyle",
      "version": "2.8.0"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "2.4.0"
    }
  ],
  "version": "4.0.1"
}

Please describe the problem or feature

The documentation for 4+ claims global user configuration is loaded on *nix systems from ~/.config/flake8.

Note that Flake8 looks for ~.flake8 on Windows and ~/.config/flake8 on Linux and other Unix systems

As of 4.0, this is no longer true.

If this is a bug report, please explain with examples (and example code) what you expected to happen and what actually happened.

#!/usr/bin/env bash
# WARNING: if you have anything in ~/.config/flake8 or ~/.flake8, this script will delete it

TEST_PROJ_DIR=~/the-docs-are-a-lie
mkdir -p $TEST_PROJ_DIR
# note: over 80 chars, under 100
echo '"23456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"' > $TEST_PROJ_DIR/test.py

# make a virtual environment to pip install flake8 into
python3 -m venv $TEST_PROJ_DIR/.venv
source $TEST_PROJ_DIR/.venv/bin/activate
pip install flake8

# "Note that Flake8 looks for ~\.flake8 on Windows and ~/.config/flake8 on Linux and other Unix systems"
# https://flake8.pycqa.org/en/4.0.1/user/configuration.html#user-configuration
mkdir -p ~/.config
echo '[flake8]' > ~/.config/flake8
echo 'max-line-length=100' >> ~/.config/flake8

echo "This following gives an E501 because flake8 doesn't load config from ~/.config/flake8 as the docs claim"
flake8 $TEST_PROJ_DIR/test.py

mv ~/.config/flake8 ~/.flake8
echo "No more line length error because we moved the config to ~/.flake8, where flake8 does manage to find it"
flake8 $TEST_PROJ_DIR/test.py

deactivate
rm -r $TEST_PROJ_DIR
rm ~/.flake8

note: flake8 only happened to find the config file in the home directory because it was a parent of the 'test proj dir'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions