summaryrefslogtreecommitdiff
path: root/flake8/main.py
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-02-17 20:47:45 -0600
committerIan Cordasco <graffatcolmingov@gmail.com>2016-02-17 20:57:24 -0600
commit533d222f525d0d8c0fecf392d6ec7d211af1d897 (patch)
treef18427267198a0760eb1b3136e5282d6c3370d5a /flake8/main.py
parentb25ad979a608ecedc2f9f08c027383765c50f59b (diff)
downloadflake8-bug/122.tar.gz
Correct usage config_file StyleGuide parameterbug/122
Previously, we passed the location for our user config file to the StyleGuide. This was intended to be a way to tell pep8's StyleGuide to use that as a user config file, but instead that became the default for the --config command-line option. This caused that to have higher priority than the project configuration file. Closes #122
Diffstat (limited to 'flake8/main.py')
-rw-r--r--flake8/main.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/flake8/main.py b/flake8/main.py
index 570b318..63bf199 100644
--- a/flake8/main.py
+++ b/flake8/main.py
@@ -3,26 +3,29 @@ import os
import re
import sys
+import pep8
import setuptools
from flake8.engine import get_parser, get_style_guide
from flake8.util import option_normalizer
if sys.platform.startswith('win'):
- DEFAULT_CONFIG = os.path.expanduser(r'~\.flake8')
+ USER_CONFIG = os.path.expanduser(r'~\.flake8')
else:
- DEFAULT_CONFIG = os.path.join(
+ USER_CONFIG = os.path.join(
os.getenv('XDG_CONFIG_HOME') or os.path.expanduser('~/.config'),
'flake8'
)
+pep8.USER_CONFIG = USER_CONFIG
+
EXTRA_IGNORE = []
def main():
"""Parse options and run checks on Python source."""
# Prepare
- flake8_style = get_style_guide(parse_argv=True, config_file=DEFAULT_CONFIG)
+ flake8_style = get_style_guide(parse_argv=True)
options = flake8_style.options
if options.install_hook:
@@ -61,8 +64,7 @@ def check_file(path, ignore=(), complexity=-1):
:param int complexity: (optional), enables the mccabe check for values > 0
"""
ignore = set(ignore).union(EXTRA_IGNORE)
- flake8_style = get_style_guide(
- config_file=DEFAULT_CONFIG, ignore=ignore, max_complexity=complexity)
+ flake8_style = get_style_guide(ignore=ignore, max_complexity=complexity)
return flake8_style.input_file(path)
@@ -74,8 +76,7 @@ def check_code(code, ignore=(), complexity=-1):
:param int complexity: (optional), enables the mccabe check for values > 0
"""
ignore = set(ignore).union(EXTRA_IGNORE)
- flake8_style = get_style_guide(
- config_file=DEFAULT_CONFIG, ignore=ignore, max_complexity=complexity)
+ flake8_style = get_style_guide(ignore=ignore, max_complexity=complexity)
return flake8_style.input_file(None, lines=code.splitlines(True))
@@ -131,9 +132,7 @@ class Flake8Command(setuptools.Command):
def run(self):
# Prepare
paths = list(self.distribution_files())
- flake8_style = get_style_guide(config_file=DEFAULT_CONFIG,
- paths=paths,
- **self.options_dict)
+ flake8_style = get_style_guide(paths=paths, **self.options_dict)
# Run the checkers
report = flake8_style.check_files()