diff --git a/mypy/test/testselfcheck.py b/mypy/test/testselfcheck.py index 9c28f323312c..5dac6ba99487 100644 --- a/mypy/test/testselfcheck.py +++ b/mypy/test/testselfcheck.py @@ -1,5 +1,8 @@ """Self check mypy package""" +import pytest # type: ignore # no pytest in typeshed +from flake8.api import legacy as flake8 # type: ignore # no falke8 in typeshed + from mypy.test.helpers import Suite, run_mypy @@ -9,3 +12,11 @@ def test_mypy_package(self) -> None: def test_testrunner(self) -> None: run_mypy(['runtests.py', 'waiter.py']) + + +class LintSuite(Suite): + def test_flake8(self) -> None: + style_guide = flake8.get_style_guide() + report = style_guide.check_files('.') + if report.total_errors != 0: + pytest.fail('Lint error', pytrace=False) diff --git a/runtests.py b/runtests.py index dcf9f4791f9c..253f4ad213a4 100755 --- a/runtests.py +++ b/runtests.py @@ -94,14 +94,6 @@ def add_pytest(self, files: List[Tuple[str, str]], coverage: bool = True) -> Non passthrough=self.verbosity), sequential=True) - def add_flake8(self, cwd: Optional[str] = None) -> None: - name = 'lint' - if not self.allow(name): - return - largs = ['flake8', '-j0'] - env = self.env - self.waiter.add(LazySubprocess(name, largs, cwd=cwd, env=env)) - def list_tasks(self) -> None: for id, task in enumerate(self.waiter.queue): print('{id}:{task}'.format(id=id, task=task.name)) @@ -308,7 +300,6 @@ def main() -> None: driver.prepend_path('MYPYPATH', [driver.cwd]) driver.prepend_path('PYTHONPATH', [driver.cwd]) - driver.add_flake8() add_pytest(driver) add_stdlibsamples(driver)