Skip to content
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

Only depend on mypy.api #8

Merged
merged 2 commits into from
Mar 16, 2018
Merged
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
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