Skip to content

Commit

Permalink
Merge pull request #8 from dmtucker/mypy-api
Browse files Browse the repository at this point in the history
Only depend on mypy.api
  • Loading branch information
dbader authored Mar 16, 2018
2 parents c406edc + d570355 commit 5cb572e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
sudo: false
language: python
python:
- "3.3"
- "3.4"
- "3.5"
- "3.6"
Expand Down
19 changes: 5 additions & 14 deletions pytest_mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[ ] Proper docs
"""
import pytest
import mypy.main
import mypy.api


def pytest_addoption(parser):
Expand Down Expand Up @@ -36,9 +36,7 @@ def __init__(self, path, parent):

def runtest(self):
"""
Run mypy on the given file. Because mypy's API is in flux
we emulate parts of mypy.main.main() here and leave it to
mypy to process it's options, for example.
Run mypy on the given file.
"""
# TODO: This should be hidden behind a debug / verbose flag.
print('Running mypy on', self.path)
Expand All @@ -52,16 +50,9 @@ def runtest(self):
# Or maybe we'll just rely on mypy.ini being present?
]

sources, options = mypy.main.process_options(mypy_argv)

try:
res = mypy.main.type_check_only(sources, None, options)
errors = res.errors
except mypy.errors.CompileError as e:
errors = e.messages

if errors:
raise MypyError('\n'.join(errors))
stdout, _, _ = mypy.api.run(args=mypy_argv)
if stdout:
raise MypyError(stdout)

def repr_failure(self, excinfo):
"""
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ def read(fname):
description='Mypy static type checker plugin for Pytest',
long_description=read('README.rst'),
py_modules=['pytest_mypy'],
install_requires=['pytest>=2.9.2', 'mypy>=0.470'],
install_requires=['pytest>=2.9.2', 'mypy~=0.570'],
classifiers=[
'Development Status :: 4 - Beta',
'Framework :: Pytest',
'Intended Audience :: Developers',
'Topic :: Software Development :: Testing',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# For more information about tox, see https://tox.readthedocs.io/en/latest/
[tox]
envlist = py33,py34,py35,flake8
envlist = py34,py35,py36,flake8

[testenv]
deps = pytest
Expand Down

0 comments on commit 5cb572e

Please sign in to comment.