Skip to content

Instantly share code, notes, and snippets.

@ambv
Created December 20, 2016 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ambv/7c7a100096413a5b9288ffe60f485f03 to your computer and use it in GitHub Desktop.
Save ambv/7c7a100096413a5b9288ffe60f485f03 to your computer and use it in GitHub Desktop.
Demonstrates how `ignore = ` overrides the default ignore list, implicitly re-enabling optional warnings in bugbear. Note the line "Overriding default value of". Change bugbear version to 16.12.2 to see the workaround in action (note the line "Optional warning B950").
#!/bin/bash -e
# Create the environment
rm -rf .v # remove old stuff if present
python3 -m venv .v
source .v/bin/activate
cd .v
pip install flake8==3.2.1
pip install flake8-bugbear==16.12.1 # the newer version works around the issue
# Create the flake8 config
cat <<EOF >.flake8
[flake8]
# implicitly re-enables B950
ignore = E501
EOF
# Create the script to evaluate
cat <<EOF >script.py
class C:
"""Long long line. Long long line. Long long line. Long long line. Long long line. Long long line. Long long line."""
__metaclass__ = object
EOF
# Run flake8 to show you high-level errors and log Implicit vs. Explicit
flake8 --config=.flake8 -vvvv -j0 script.py 2>flake8_verbose.log || echo "flake8 correctly raised issues."
cat flake8_verbose.log | grep -E '(flake8\.options\.manager|flake8\.options\.aggregator|flake8\.style_guide|flake8\.bugbear)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment