mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-11 23:34:17 +00:00
Tentative independence from vendored pep8
I'm fairly certain we no longer need the copy we had of pep8.
This commit is contained in:
parent
c17aeb3848
commit
b2135a0e0e
5 changed files with 35 additions and 136 deletions
|
|
@ -1,3 +1,2 @@
|
||||||
#
|
|
||||||
|
|
||||||
__version__ = '1.7.0'
|
__version__ = '1.7.0'
|
||||||
|
|
|
||||||
|
|
@ -1,113 +0,0 @@
|
||||||
# (c) 2005 Divmod, Inc. See LICENSE file for details
|
|
||||||
|
|
||||||
|
|
||||||
class Message(object):
|
|
||||||
message = ''
|
|
||||||
message_args = ()
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno):
|
|
||||||
self.filename = filename
|
|
||||||
self.lineno = lineno
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return '%s:%s: %s' % (self.filename, self.lineno,
|
|
||||||
self.message % self.message_args)
|
|
||||||
|
|
||||||
def __lt__(self, other):
|
|
||||||
if self.filename != other.filename:
|
|
||||||
return self.filename < other.filename
|
|
||||||
return self.lineno < other.lineno
|
|
||||||
|
|
||||||
|
|
||||||
class UnusedImport(Message):
|
|
||||||
message = 'W402 %r imported but unused'
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno, name):
|
|
||||||
Message.__init__(self, filename, lineno)
|
|
||||||
self.message_args = (name,)
|
|
||||||
|
|
||||||
|
|
||||||
class RedefinedWhileUnused(Message):
|
|
||||||
message = 'W801 redefinition of unused %r from line %r'
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno, name, orig_lineno):
|
|
||||||
Message.__init__(self, filename, lineno)
|
|
||||||
self.message_args = (name, orig_lineno)
|
|
||||||
|
|
||||||
|
|
||||||
class ImportShadowedByLoopVar(Message):
|
|
||||||
message = 'W403 import %r from line %r shadowed by loop variable'
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno, name, orig_lineno):
|
|
||||||
Message.__init__(self, filename, lineno)
|
|
||||||
self.message_args = (name, orig_lineno)
|
|
||||||
|
|
||||||
|
|
||||||
class ImportStarUsed(Message):
|
|
||||||
message = "W404 'from %s import *' used; unable to detect undefined names"
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno, modname):
|
|
||||||
Message.__init__(self, filename, lineno)
|
|
||||||
self.message_args = (modname,)
|
|
||||||
|
|
||||||
|
|
||||||
class UndefinedName(Message):
|
|
||||||
message = 'W802 undefined name %r'
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno, name):
|
|
||||||
Message.__init__(self, filename, lineno)
|
|
||||||
self.message_args = (name,)
|
|
||||||
|
|
||||||
|
|
||||||
class UndefinedExport(Message):
|
|
||||||
message = 'W803 undefined name %r in __all__'
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno, name):
|
|
||||||
Message.__init__(self, filename, lineno)
|
|
||||||
self.message_args = (name,)
|
|
||||||
|
|
||||||
|
|
||||||
class UndefinedLocal(Message):
|
|
||||||
message = "W804 local variable %r (defined in enclosing scope on line " \
|
|
||||||
"%r) referenced before assignment"
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno, name, orig_lineno):
|
|
||||||
Message.__init__(self, filename, lineno)
|
|
||||||
self.message_args = (name, orig_lineno)
|
|
||||||
|
|
||||||
|
|
||||||
class DuplicateArgument(Message):
|
|
||||||
message = 'W805 duplicate argument %r in function definition'
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno, name):
|
|
||||||
Message.__init__(self, filename, lineno)
|
|
||||||
self.message_args = (name,)
|
|
||||||
|
|
||||||
|
|
||||||
class RedefinedFunction(Message):
|
|
||||||
message = 'W806 redefinition of function %r from line %r'
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno, name, orig_lineno):
|
|
||||||
Message.__init__(self, filename, lineno)
|
|
||||||
self.message_args = (name, orig_lineno)
|
|
||||||
|
|
||||||
|
|
||||||
class LateFutureImport(Message):
|
|
||||||
message = 'W405 future import(s) %r after other statements'
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno, names):
|
|
||||||
Message.__init__(self, filename, lineno)
|
|
||||||
self.message_args = (names,)
|
|
||||||
|
|
||||||
|
|
||||||
class UnusedVariable(Message):
|
|
||||||
"""
|
|
||||||
Indicates that a variable has been explicity assigned to but not actually
|
|
||||||
used.
|
|
||||||
"""
|
|
||||||
|
|
||||||
message = 'W806 local variable %r is assigned to but never used'
|
|
||||||
|
|
||||||
def __init__(self, filename, lineno, names):
|
|
||||||
Message.__init__(self, filename, lineno)
|
|
||||||
self.message_args = (names,)
|
|
||||||
|
|
@ -9,10 +9,10 @@ import optparse
|
||||||
from subprocess import PIPE, Popen
|
from subprocess import PIPE, Popen
|
||||||
import select
|
import select
|
||||||
|
|
||||||
from flake8 import pep8
|
|
||||||
from flake8 import mccabe
|
from flake8 import mccabe
|
||||||
from flake8.util import skip_file
|
from flake8.util import skip_file
|
||||||
from flake8 import __version__
|
from flake8 import __version__
|
||||||
|
import pep8
|
||||||
import flakey
|
import flakey
|
||||||
|
|
||||||
pep8style = None
|
pep8style = None
|
||||||
|
|
@ -66,14 +66,13 @@ def read_stdin():
|
||||||
return sys.stdin.read()
|
return sys.stdin.read()
|
||||||
|
|
||||||
|
|
||||||
def version(option, opt, value, parser):
|
def get_parser():
|
||||||
parser.print_usage()
|
"""Create a custom OptionParser"""
|
||||||
parser.print_version()
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
def version(option, opt, value, parser):
|
||||||
def main():
|
parser.print_usage()
|
||||||
global pep8style
|
parser.print_version()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
# Create our own parser
|
# Create our own parser
|
||||||
parser = optparse.OptionParser('%prog [options]', version=version)
|
parser = optparse.OptionParser('%prog [options]', version=version)
|
||||||
|
|
@ -93,6 +92,13 @@ def main():
|
||||||
parser.add_option('-V', '--version', action='callback',
|
parser.add_option('-V', '--version', action='callback',
|
||||||
callback=version,
|
callback=version,
|
||||||
help='Print the version info for flake8')
|
help='Print the version info for flake8')
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
global pep8style
|
||||||
|
|
||||||
|
parser = get_parser()
|
||||||
# parse our flags
|
# parse our flags
|
||||||
opts, args = parser.parse_args()
|
opts, args = parser.parse_args()
|
||||||
|
|
||||||
|
|
@ -165,8 +171,8 @@ def _initpep8():
|
||||||
global pep8style
|
global pep8style
|
||||||
if pep8style is None:
|
if pep8style is None:
|
||||||
pep8style = pep8.StyleGuide(config_file=True)
|
pep8style = pep8.StyleGuide(config_file=True)
|
||||||
#pep8style.options.physical_checks = pep8.find_checks('physical_line')
|
pep8style.options.physical_checks = pep8.find_checks('physical_line')
|
||||||
#pep8style.options.logical_checks = pep8.find_checks('logical_line')
|
pep8style.options.logical_checks = pep8.find_checks('logical_line')
|
||||||
pep8style.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
|
pep8style.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
|
||||||
pep8style.options.messages = {}
|
pep8style.options.messages = {}
|
||||||
pep8style.options.max_line_length = 79
|
pep8style.options.max_line_length = 79
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from flake8.pyflakes import check
|
from flakey import check, print_messages
|
||||||
|
|
||||||
|
|
||||||
code = """
|
code = """
|
||||||
|
|
@ -49,11 +49,16 @@ class TestFlake(TestCase):
|
||||||
|
|
||||||
def test_exception(self):
|
def test_exception(self):
|
||||||
for c in (code, code2, code3):
|
for c in (code, code2, code3):
|
||||||
warnings = check(code)
|
warnings = check(code, '(stdin)')
|
||||||
self.assertEqual(warnings, 0, code)
|
warnings = print_messages(warnings)
|
||||||
|
self.assertEqual(warnings, 0)
|
||||||
|
|
||||||
def test_from_import_exception_in_scope(self):
|
def test_from_import_exception_in_scope(self):
|
||||||
self.assertEqual(check(code_from_import_exception), 0)
|
warnings = check(code_from_import_exception, '(stdin)')
|
||||||
|
warnings = print_messages(warnings)
|
||||||
|
self.assertEqual(warnings, 0)
|
||||||
|
|
||||||
def test_import_exception_in_scope(self):
|
def test_import_exception_in_scope(self):
|
||||||
self.assertEqual(check(code_import_exception), 0)
|
warnings = check(code_import_exception, '(stdin)')
|
||||||
|
warnings = print_messages(warnings)
|
||||||
|
self.assertEqual(warnings, 0)
|
||||||
|
|
|
||||||
16
setup.py
16
setup.py
|
|
@ -2,7 +2,7 @@ import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
ispy3 = sys.version_info[0] == 3
|
ispy3 = sys.version_info[0] == 3
|
||||||
iswin = os.name == 'nt'
|
iswin = os.name == 'nt'
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
scripts = ["flake8/flake8"]
|
scripts = ["flake8/flake8"]
|
||||||
|
|
@ -14,9 +14,10 @@ else:
|
||||||
try:
|
try:
|
||||||
from setuptools import setup # NOQA
|
from setuptools import setup # NOQA
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'entry_points':
|
'entry_points': {
|
||||||
{'distutils.commands': ['flake8 = flake8.run:Flake8Command'],
|
'distutils.commands': ['flake8 = flake8.run:Flake8Command'],
|
||||||
'console_scripts': ['flake8 = flake8.run:main']},
|
'console_scripts': ['flake8 = flake8.run:main']
|
||||||
|
},
|
||||||
'tests_require': ['nose'],
|
'tests_require': ['nose'],
|
||||||
'test_suite': 'nose.collector',
|
'test_suite': 'nose.collector',
|
||||||
}
|
}
|
||||||
|
|
@ -39,7 +40,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>=2.0", "pep8"],
|
requires=["flakey (>=2.0)", "pep8 (>=1.4)"],
|
||||||
long_description=README,
|
long_description=README,
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Environment :: Console",
|
"Environment :: Console",
|
||||||
|
|
@ -48,5 +49,6 @@ setup(
|
||||||
"Programming Language :: Python",
|
"Programming Language :: Python",
|
||||||
"Topic :: Software Development",
|
"Topic :: Software Development",
|
||||||
"Topic :: Utilities",
|
"Topic :: Utilities",
|
||||||
],
|
],
|
||||||
**kwargs)
|
**kwargs
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue