mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-02 03:46:53 +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'
|
||||
|
|
|
|||
|
|
@ -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
|
||||
import select
|
||||
|
||||
from flake8 import pep8
|
||||
from flake8 import mccabe
|
||||
from flake8.util import skip_file
|
||||
from flake8 import __version__
|
||||
import pep8
|
||||
import flakey
|
||||
|
||||
pep8style = None
|
||||
|
|
@ -66,14 +66,13 @@ def read_stdin():
|
|||
return sys.stdin.read()
|
||||
|
||||
|
||||
def version(option, opt, value, parser):
|
||||
parser.print_usage()
|
||||
parser.print_version()
|
||||
sys.exit(0)
|
||||
def get_parser():
|
||||
"""Create a custom OptionParser"""
|
||||
|
||||
|
||||
def main():
|
||||
global pep8style
|
||||
def version(option, opt, value, parser):
|
||||
parser.print_usage()
|
||||
parser.print_version()
|
||||
sys.exit(0)
|
||||
|
||||
# Create our own parser
|
||||
parser = optparse.OptionParser('%prog [options]', version=version)
|
||||
|
|
@ -93,6 +92,13 @@ def main():
|
|||
parser.add_option('-V', '--version', action='callback',
|
||||
callback=version,
|
||||
help='Print the version info for flake8')
|
||||
return parser
|
||||
|
||||
|
||||
def main():
|
||||
global pep8style
|
||||
|
||||
parser = get_parser()
|
||||
# parse our flags
|
||||
opts, args = parser.parse_args()
|
||||
|
||||
|
|
@ -165,8 +171,8 @@ def _initpep8():
|
|||
global pep8style
|
||||
if pep8style is None:
|
||||
pep8style = pep8.StyleGuide(config_file=True)
|
||||
#pep8style.options.physical_checks = pep8.find_checks('physical_line')
|
||||
#pep8style.options.logical_checks = pep8.find_checks('logical_line')
|
||||
pep8style.options.physical_checks = pep8.find_checks('physical_line')
|
||||
pep8style.options.logical_checks = pep8.find_checks('logical_line')
|
||||
pep8style.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
|
||||
pep8style.options.messages = {}
|
||||
pep8style.options.max_line_length = 79
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from unittest import TestCase
|
||||
from flake8.pyflakes import check
|
||||
from flakey import check, print_messages
|
||||
|
||||
|
||||
code = """
|
||||
|
|
@ -49,11 +49,16 @@ class TestFlake(TestCase):
|
|||
|
||||
def test_exception(self):
|
||||
for c in (code, code2, code3):
|
||||
warnings = check(code)
|
||||
self.assertEqual(warnings, 0, code)
|
||||
warnings = check(code, '(stdin)')
|
||||
warnings = print_messages(warnings)
|
||||
self.assertEqual(warnings, 0)
|
||||
|
||||
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):
|
||||
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
|
||||
|
||||
ispy3 = sys.version_info[0] == 3
|
||||
iswin = os.name == 'nt'
|
||||
iswin = os.name == 'nt'
|
||||
|
||||
kwargs = {}
|
||||
scripts = ["flake8/flake8"]
|
||||
|
|
@ -14,9 +14,10 @@ else:
|
|||
try:
|
||||
from setuptools import setup # NOQA
|
||||
kwargs = {
|
||||
'entry_points':
|
||||
{'distutils.commands': ['flake8 = flake8.run:Flake8Command'],
|
||||
'console_scripts': ['flake8 = flake8.run:main']},
|
||||
'entry_points': {
|
||||
'distutils.commands': ['flake8 = flake8.run:Flake8Command'],
|
||||
'console_scripts': ['flake8 = flake8.run:main']
|
||||
},
|
||||
'tests_require': ['nose'],
|
||||
'test_suite': 'nose.collector',
|
||||
}
|
||||
|
|
@ -39,7 +40,7 @@ setup(
|
|||
url="http://bitbucket.org/tarek/flake8",
|
||||
packages=["flake8", "flake8.tests"],
|
||||
scripts=scripts,
|
||||
requires=["flakey>=2.0", "pep8"],
|
||||
requires=["flakey (>=2.0)", "pep8 (>=1.4)"],
|
||||
long_description=README,
|
||||
classifiers=[
|
||||
"Environment :: Console",
|
||||
|
|
@ -48,5 +49,6 @@ setup(
|
|||
"Programming Language :: Python",
|
||||
"Topic :: Software Development",
|
||||
"Topic :: Utilities",
|
||||
],
|
||||
**kwargs)
|
||||
],
|
||||
**kwargs
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue