Skip to content

Commit da1aa55

Browse files
authored
Merge pull request #11 from mkurnikov/fix-for-730
0.730 compatibility, correct reported error line
2 parents 8faf0df + f1327b3 commit da1aa55

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

pytest_mypy/collect.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ class SafeLineLoader(yaml.SafeLoader):
3737
def construct_mapping(self, node, deep=False):
3838
mapping = super().construct_mapping(node, deep=deep)
3939
# Add 1 so line numbering starts at 1
40-
mapping['__line__'] = node.start_mark.line + 1
40+
starting_line = node.start_mark.line + 1
41+
for (title_node, contents_node) in node.value:
42+
if title_node.value == 'main':
43+
starting_line = title_node.start_mark.line + 1
44+
mapping['__line__'] = starting_line
4145
return mapping
4246

4347

pytest_mypy/item.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ def prepare_mypy_cmd_options(self, execution_path: Path) -> List[str]:
249249
mypy_cmd_options = [
250250
'--show-traceback',
251251
'--no-silence-site-packages',
252+
'--no-error-summary',
253+
'--no-pretty',
254+
'--hide-error-context'
252255
]
253256
if not self.disable_cache:
254257
mypy_cmd_options.extend([

pytest_mypy/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def extract_errors_from_comments(fname: str, input_lines: List[str]) -> List[str
289289

290290

291291
def get_func_first_lnum(attr: Callable[..., None]) -> Optional[Tuple[int, List[str]]]:
292-
lines, _ = inspect.getsourcelines(attr)
292+
lines, _ = inspect.getsourcelines(attr) # type: ignore[arg-type]
293293
for lnum, line in enumerate(lines):
294294
no_space_line = line.strip()
295295
if f'def {attr.__name__}' in no_space_line:

setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
import sys
2-
31
from setuptools import setup
42

53
with open('README.md', 'r') as f:
64
readme = f.read()
75

86
dependencies = [
97
'pytest',
10-
'mypy',
8+
'mypy>=0.730',
119
'decorator',
1210
'capturer',
1311
'pyyaml'
1412
]
1513

1614
setup(
1715
name='pytest-mypy-plugins',
18-
version='1.0.3',
16+
version='1.1.0',
1917
description='pytest plugin for writing tests for mypy plugins',
2018
long_description=readme,
2119
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)