Skip to content

Commit

Permalink
Add lint command
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewwithanm committed Jul 31, 2013
1 parent ece61a5 commit 2515e9e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[flake8]
ignore = E501
38 changes: 36 additions & 2 deletions setup.py
Expand Up @@ -2,7 +2,7 @@
import codecs
import os
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
from setuptools.command.test import test as TestCommand, Command


read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read()
Expand All @@ -25,6 +25,37 @@ def run_tests(self):
raise SystemExit(errno)


class LintCommand(Command):
"""
A copy of flake8's Flake8Command
"""
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):
from flake8.engine import get_style_guide
flake8_style = get_style_guide(config_file='setup.cfg')
paths = self.distribution_files()
report = flake8_style.check_files(paths)
raise SystemExit(report.total_errors > 0)


setup(
name='markdownify',
description='Convert HTML to markdown.',
Expand All @@ -37,6 +68,9 @@ def run_tests(self):
packages=find_packages(),
zip_safe=False,
include_package_data=True,
setup_requires=[
'flake8',
],
tests_require=[
'pytest',
],
Expand All @@ -55,8 +89,8 @@ def run_tests(self):
'Programming Language :: Python :: 2.7',
'Topic :: Utilities'
],
setup_requires=[],
cmdclass={
'test': PyTest,
'lint': LintCommand,
},
)

0 comments on commit 2515e9e

Please sign in to comment.