mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-13 08:04:18 +00:00
add Flake8Command, a setuptools command
This runs flake8 with the default options on all Python files referenced by a package's setup.py. It works with both package-based and py_modules-based file lists.
This commit is contained in:
parent
2f9825a6af
commit
2e04e30d51
2 changed files with 40 additions and 0 deletions
|
|
@ -164,5 +164,40 @@ 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
|
||||||
|
|
||||||
|
if self.distribution.py_modules:
|
||||||
|
for filename in self.distribution.py_modules:
|
||||||
|
yield "%s.py" % filename
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
_initpep8()
|
||||||
|
|
||||||
|
warnings = 0
|
||||||
|
for path in _get_python_files(self.distribution_files()):
|
||||||
|
warnings += check_file(path)
|
||||||
|
|
||||||
|
raise SystemExit(warnings > 0)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
5
setup.py
5
setup.py
|
|
@ -24,6 +24,11 @@ setup(
|
||||||
url="http://bitbucket.org/tarek/flake8",
|
url="http://bitbucket.org/tarek/flake8",
|
||||||
packages=["flake8", "flake8.tests"],
|
packages=["flake8", "flake8.tests"],
|
||||||
scripts=["flake8/flake8"],
|
scripts=["flake8/flake8"],
|
||||||
|
entry_points = {
|
||||||
|
"distutils.commands": [
|
||||||
|
"flake8 = flake8.run:Flake8Command",
|
||||||
|
],
|
||||||
|
},
|
||||||
long_description=README,
|
long_description=README,
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Environment :: Console",
|
"Environment :: Console",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue