Skip to content

Commit

Permalink
Revert "Merge pull request prospector-dev#349 from rik/mypy-730-compat"
Browse files Browse the repository at this point in the history
This reverts commit 002d7ea, reversing
changes made to 71a9c37.
  • Loading branch information
rik committed Nov 18, 2019
1 parent 00a33d9 commit 4dadee8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 57 deletions.
8 changes: 3 additions & 5 deletions prospector/tools/mypy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ def configure(self, prospector_config, _):
def run(self, found_files):
paths = [path for path in found_files.iter_module_paths()]
paths.extend(self.options)
report, _ = self.checker.run(paths)
messages = report.splitlines()
if messages and messages[-1].startswith(('Found', 'Success')):
del messages[-1]
result = self.checker.run(paths)
report, _ = result[0], result[1:] # noqa

return [format_message(message) for message in messages]
return [format_message(message) for message in report.splitlines()]
53 changes: 1 addition & 52 deletions tests/tools/mypy/test_mypy_tool.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# -*- coding: utf-8 -*-
import sys
from unittest import SkipTest, TestCase

from prospector.message import Location, Message

if sys.version_info >= (3, 0):
from unittest import mock
else:
import mock


try:
from prospector.tools.mypy import MypyTool, format_message
from prospector.tools.mypy import format_message
except ImportError:
raise SkipTest

Expand Down Expand Up @@ -47,47 +40,3 @@ def test_format_message_without_character(self):
source="mypy", code="error", location=location, message="Important error"
)
self.assertEqual(format_message("file.py:17: error: Important error"), expected)

def test_pre730_format(self):
tool = MypyTool()
found_files = mock.MagicMock()
output = ['file.py:17: error: Important error', 'file.py:17:2: error: Important error']

with mock.patch('mypy.api.run') as mock_mypy:
mock_mypy.return_value = ('\n'.join(output), "unused")
messages = tool.run(found_files)

self.assertEqual(len(messages), len(output))

def test_pre730_format_empty(self):
tool = MypyTool()
found_files = mock.MagicMock()
output = []

with mock.patch('mypy.api.run') as mock_mypy:
mock_mypy.return_value = ('\n'.join(output), "unused")
messages = tool.run(found_files)

self.assertEqual(len(messages), len(output))

def test_post730_format(self):
tool = MypyTool()
found_files = mock.MagicMock()
output = ['file.py:17: error: Important error', 'file.py:17:2: error: Important error', 'Found 2 errors in 1 file (checked 63 source files)']

with mock.patch('mypy.api.run') as mock_mypy:
mock_mypy.return_value = ('\n'.join(output), "unused")
messages = tool.run(found_files)

self.assertEqual(len(messages), len(output) - 1)

def test_post730_format_empty(self):
tool = MypyTool()
found_files = mock.MagicMock()
output = ['Success: no issues found in 9 source files']

with mock.patch('mypy.api.run') as mock_mypy:
mock_mypy.return_value = ('\n'.join(output), "unused")
messages = tool.run(found_files)

self.assertEqual(len(messages), len(output) - 1)

0 comments on commit 4dadee8

Please sign in to comment.