mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-07 13:36:54 +00:00
Start the refactor.
This commit is contained in:
parent
625694094c
commit
31bcca53f9
3 changed files with 27 additions and 17 deletions
|
|
@ -92,8 +92,6 @@ The format is simple: "Okay" or error/warning code followed by colon
|
||||||
and space, the rest of the line is example source code. If you put 'r'
|
and space, the rest of the line is example source code. If you put 'r'
|
||||||
before the docstring, you can use \n for newline and \t for tab.
|
before the docstring, you can use \n for newline and \t for tab.
|
||||||
"""
|
"""
|
||||||
from flake8.pyflakes import __version__ as pyflakes_version
|
|
||||||
from flake8 import __version__ as flake8_version
|
|
||||||
|
|
||||||
__version__ = '1.3.5a'
|
__version__ = '1.3.5a'
|
||||||
|
|
||||||
|
|
@ -1853,11 +1851,7 @@ def process_options(arglist=None, parse_argv=False, config_file=None):
|
||||||
if config_file is True:
|
if config_file is True:
|
||||||
config_file = DEFAULT_CONFIG
|
config_file = DEFAULT_CONFIG
|
||||||
|
|
||||||
version = '%s (pyflakes: %s, pep8: %s)' % \
|
parser = OptionParser(version=__version__,
|
||||||
(flake8_version, pyflakes_version, __version__)
|
|
||||||
|
|
||||||
|
|
||||||
parser = OptionParser(version=version,
|
|
||||||
usage="%prog [options] input ...")
|
usage="%prog [options] input ...")
|
||||||
parser.config_options = [
|
parser.config_options = [
|
||||||
'builtins', 'count', 'exclude', 'filename', 'format', 'ignore',
|
'builtins', 'count', 'exclude', 'filename', 'format', 'ignore',
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,17 @@ Implementation of the command-line I{flake8} tool.
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import optparse
|
||||||
from subprocess import PIPE, Popen
|
from subprocess import PIPE, Popen
|
||||||
import select
|
import select
|
||||||
try:
|
|
||||||
from StringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from io import StringIO # NOQA
|
|
||||||
|
|
||||||
from flake8.util import skip_file
|
|
||||||
from flake8 import pep8
|
from flake8 import pep8
|
||||||
from flake8 import pyflakes
|
|
||||||
from flake8 import mccabe
|
from flake8 import mccabe
|
||||||
|
from flake8.util import skip_file
|
||||||
|
from flake8 import __version__ as flake8_version
|
||||||
|
from flakey import __version__ as flakey_version
|
||||||
|
from flakey import checker
|
||||||
|
from flakey.scripts import flakey
|
||||||
|
|
||||||
pep8style = None
|
pep8style = None
|
||||||
|
|
||||||
|
|
@ -23,7 +23,8 @@ pep8style = None
|
||||||
def check_file(path, ignore=(), complexity=-1):
|
def check_file(path, ignore=(), complexity=-1):
|
||||||
if pep8style.excluded(path):
|
if pep8style.excluded(path):
|
||||||
return 0
|
return 0
|
||||||
warnings = pyflakes.checkPath(path, ignore)
|
#warnings = flakey.checkPath(path, ignore)
|
||||||
|
warnings = flakey.checkPath(path)
|
||||||
warnings += pep8style.input_file(path)
|
warnings += pep8style.input_file(path)
|
||||||
if complexity > -1:
|
if complexity > -1:
|
||||||
warnings += mccabe.get_module_complexity(path, complexity)
|
warnings += mccabe.get_module_complexity(path, complexity)
|
||||||
|
|
@ -31,7 +32,7 @@ def check_file(path, ignore=(), complexity=-1):
|
||||||
|
|
||||||
|
|
||||||
def check_code(code, ignore=(), complexity=-1):
|
def check_code(code, ignore=(), complexity=-1):
|
||||||
warnings = pyflakes.check(code, ignore, 'stdin')
|
warnings = flakey.check(code, ignore, 'stdin')
|
||||||
warnings += pep8style.input_file(None, lines=code.split('\n'))
|
warnings += pep8style.input_file(None, lines=code.split('\n'))
|
||||||
if complexity > -1:
|
if complexity > -1:
|
||||||
warnings += mccabe.get_code_complexity(code, complexity)
|
warnings += mccabe.get_code_complexity(code, complexity)
|
||||||
|
|
@ -66,8 +67,22 @@ def read_stdin():
|
||||||
return sys.stdin.read()
|
return sys.stdin.read()
|
||||||
|
|
||||||
|
|
||||||
|
def version(option, opt, value, parser):
|
||||||
|
parser.print_usage()
|
||||||
|
parser.print_version()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global pep8style
|
global pep8style
|
||||||
|
parser = optparse.OptionParser('%prog [options]', version=version)
|
||||||
|
parser.version = '{0} (pep8: {1}, flakey: {2})'.format(
|
||||||
|
flake8_version, pep8.__version__, flakey_version)
|
||||||
|
parser.remove_option('--version')
|
||||||
|
parser.add_option('-v', '--version', action='callback',
|
||||||
|
callback=version,
|
||||||
|
help='Print the version info for flake8')
|
||||||
|
parser.parse_args()
|
||||||
pep8style = pep8.StyleGuide(parse_argv=True, config_file=True)
|
pep8style = pep8.StyleGuide(parse_argv=True, config_file=True)
|
||||||
options = pep8style.options
|
options = pep8style.options
|
||||||
complexity = options.max_complexity
|
complexity = options.max_complexity
|
||||||
|
|
@ -76,8 +91,8 @@ def main():
|
||||||
stdin = None
|
stdin = None
|
||||||
|
|
||||||
if builtins:
|
if builtins:
|
||||||
orig_builtins = set(pyflakes._MAGIC_GLOBALS)
|
orig_builtins = set(checker._MAGIC_GLOBALS)
|
||||||
pyflakes._MAGIC_GLOBALS = orig_builtins | builtins
|
checker._MAGIC_GLOBALS = orig_builtins | builtins
|
||||||
|
|
||||||
if pep8style.paths and options.filename is not None:
|
if pep8style.paths and options.filename is not None:
|
||||||
for path in _get_python_files(pep8style.paths):
|
for path in _get_python_files(pep8style.paths):
|
||||||
|
|
|
||||||
1
setup.py
1
setup.py
|
|
@ -39,6 +39,7 @@ setup(
|
||||||
url="http://bitbucket.org/tarek/flake8",
|
url="http://bitbucket.org/tarek/flake8",
|
||||||
packages=["flake8", "flake8.tests"],
|
packages=["flake8", "flake8.tests"],
|
||||||
scripts=scripts,
|
scripts=scripts,
|
||||||
|
requires=['flakey'],
|
||||||
long_description=README,
|
long_description=README,
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Environment :: Console",
|
"Environment :: Console",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue