Skip to content

Move linting to pytest #5270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions mypy/test/testselfcheck.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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)
9 changes: 0 additions & 9 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)

Expand Down