mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-18 01:49:52 +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
|
- Jannis Leidel
|
||||||
- Miki Tebeka
|
- Miki Tebeka
|
||||||
- David Cramer
|
- 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 =
|
entry-points =
|
||||||
flake8=flake8.run:main
|
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
|
Original projects
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ class _PEP8Options(object):
|
||||||
benchmark = False
|
benchmark = False
|
||||||
testsuite = ''
|
testsuite = ''
|
||||||
doctest = False
|
doctest = False
|
||||||
|
max_line_length = pep8.MAX_LINE_LENGTH
|
||||||
|
|
||||||
|
|
||||||
def _initpep8():
|
def _initpep8():
|
||||||
|
|
@ -171,5 +172,50 @@ def hg_hook(ui, repo, **kwargs):
|
||||||
|
|
||||||
return 0
|
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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
8
setup.py
8
setup.py
|
|
@ -1,4 +1,4 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
ispy3 = sys.version_info[0] == 3
|
ispy3 = sys.version_info[0] == 3
|
||||||
|
|
@ -14,11 +14,11 @@ else:
|
||||||
try:
|
try:
|
||||||
from setuptools import setup # NOQA
|
from setuptools import setup # NOQA
|
||||||
kwargs = {
|
kwargs = {
|
||||||
|
'entry_points':
|
||||||
|
{'distutils.commands': ['flake8 = flake8.run:Flake8Command'],
|
||||||
|
'console_scripts': ['flake8 = flake8.run:main']},
|
||||||
'tests_require': ['nose'],
|
'tests_require': ['nose'],
|
||||||
'test_suite': 'nose.collector',
|
'test_suite': 'nose.collector',
|
||||||
'entry_points': {
|
|
||||||
'console_scripts': ['flake8 = flake8.run:main']
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from distutils.core import setup # NOQA
|
from distutils.core import setup # NOQA
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue