mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-04 20:26:53 +00:00
Merged changes from origin
This commit is contained in:
commit
164a32126c
4 changed files with 76 additions and 4 deletions
|
|
@ -13,3 +13,4 @@ Contributors (by order of appearance) :
|
|||
- Jannis Leidel
|
||||
- Miki Tebeka
|
||||
- David Cramer
|
||||
- Peter Teichman
|
||||
|
|
|
|||
25
README
25
README
|
|
@ -123,6 +123,31 @@ In order to use Flake8 inside a buildout, edit your buildout.cfg and add this::
|
|||
entry-points =
|
||||
flake8=flake8.run:main
|
||||
|
||||
|
||||
setuptools integration
|
||||
======================
|
||||
|
||||
If setuptools is available, Flake8 provides a command that checks the
|
||||
Python files declared by your project. To use it, add flake8 to your
|
||||
setup_requires::
|
||||
|
||||
setup(
|
||||
name="project",
|
||||
packages=["project"],
|
||||
|
||||
setup_requires=[
|
||||
"flake8"
|
||||
]
|
||||
)
|
||||
|
||||
Running ``python setup.py flake8`` on the command line will check the
|
||||
files listed in your ``py_modules`` and ``packages``. If any warnings
|
||||
are found, the command will exit with an error code::
|
||||
|
||||
$ python setup.py flake8
|
||||
|
||||
|
||||
|
||||
Original projects
|
||||
=================
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ class _PEP8Options(object):
|
|||
benchmark = False
|
||||
testsuite = ''
|
||||
doctest = False
|
||||
max_line_length = pep8.MAX_LINE_LENGTH
|
||||
|
||||
|
||||
def _initpep8():
|
||||
|
|
@ -171,5 +172,50 @@ def hg_hook(ui, repo, **kwargs):
|
|||
|
||||
return 0
|
||||
|
||||
|
||||
try:
|
||||
from setuptools import Command
|
||||
except ImportError:
|
||||
Flake8Command = None
|
||||
else:
|
||||
class Flake8Command(Command):
|
||||
description = "Run flake8 on modules registered in setuptools"
|
||||
user_options = []
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def distribution_files(self):
|
||||
if self.distribution.packages:
|
||||
for package in self.distribution.packages:
|
||||
yield package.replace(".", os.path.sep)
|
||||
|
||||
if self.distribution.py_modules:
|
||||
for filename in self.distribution.py_modules:
|
||||
yield "%s.py" % filename
|
||||
|
||||
def run(self):
|
||||
global pep8style
|
||||
pep8style = pep8.StyleGuide(config_file=True)
|
||||
|
||||
_initpep8()
|
||||
|
||||
# _get_python_files can produce the same file several
|
||||
# times, if one of its paths is a parent of another. Keep
|
||||
# a set of checked files to de-duplicate.
|
||||
checked = set()
|
||||
|
||||
warnings = 0
|
||||
for path in _get_python_files(self.distribution_files()):
|
||||
if path not in checked:
|
||||
warnings += check_file(path)
|
||||
checked.add(path)
|
||||
|
||||
raise SystemExit(warnings > 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
|||
8
setup.py
8
setup.py
|
|
@ -1,4 +1,4 @@
|
|||
import sys
|
||||
import sys
|
||||
import os
|
||||
|
||||
ispy3 = sys.version_info[0] == 3
|
||||
|
|
@ -14,11 +14,11 @@ else:
|
|||
try:
|
||||
from setuptools import setup # NOQA
|
||||
kwargs = {
|
||||
'entry_points':
|
||||
{'distutils.commands': ['flake8 = flake8.run:Flake8Command'],
|
||||
'console_scripts': ['flake8 = flake8.run:main']},
|
||||
'tests_require': ['nose'],
|
||||
'test_suite': 'nose.collector',
|
||||
'entry_points': {
|
||||
'console_scripts': ['flake8 = flake8.run:main']
|
||||
},
|
||||
}
|
||||
except ImportError:
|
||||
from distutils.core import setup # NOQA
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue