Skip to content

Commit 2459905

Browse files
authored
Fix build (#113)
* Fix tests broken by mypy message changes. * Fix type changes needed for newer mypy version, plus formatting.
1 parent 2a4fcd4 commit 2459905

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

pytest_mypy_plugins/collect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def construct_mapping(self, node: yaml.MappingNode, deep: bool = False) -> Dict[
7777
mapping = super().construct_mapping(node, deep=deep)
7878
# Add 1 so line numbering starts at 1
7979
starting_line = node.start_mark.line + 1
80-
for (title_node, contents_node) in node.value:
80+
for title_node, contents_node in node.value:
8181
if title_node.value == "main":
8282
starting_line = title_node.start_mark.line + 1
8383
mapping["__line__"] = starting_line

pytest_mypy_plugins/item.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class ReturnCodes:
8787
FATAL_ERROR = 2
8888

8989

90-
def run_mypy_typechecking(cmd_options: List[str]) -> int:
90+
def run_mypy_typechecking(cmd_options: List[str]) -> Optional[Union[str, int]]:
9191
fscache = FileSystemCache()
9292
sources, options = process_options(cmd_options, fscache=fscache)
9393

@@ -215,7 +215,7 @@ def typecheck_in_new_subprocess(
215215

216216
def typecheck_in_same_process(
217217
self, execution_path: Path, mypy_cmd_options: List[Any]
218-
) -> Tuple[int, Tuple[str, str]]:
218+
) -> Tuple[Optional[Union[str, int]], Tuple[str, str]]:
219219
with utils.temp_environ(), utils.temp_path(), utils.temp_sys_modules():
220220
# add custom environment variables
221221
for key, val in self.environment_variables.items():
@@ -241,7 +241,6 @@ def runtest(self) -> None:
241241
temp_dir = tempfile.TemporaryDirectory(prefix="pytest-mypy-", dir=self.root_directory)
242242

243243
except (FileNotFoundError, PermissionError, NotADirectoryError) as e:
244-
245244
raise TypecheckAssertionError(
246245
error_message=f"Testing base directory {self.root_directory} must exist and be writable"
247246
) from e

pytest_mypy_plugins/tests/test-parametrized.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444
...
4545
out: |
4646
main:2: note: Revealed type is "{{ rt }}"
47-
main:4: error: Unsupported operand types for / ("str" and "int")
47+
main:4: error: Unsupported operand types for / ("str" and "int") [operator]

pytest_mypy_plugins/tests/test-paths-from-env.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import extra_module
44
extra_module.extra_fn()
55
6-
extra_module.missing() # E: Module has no attribute "missing"
6+
extra_module.missing() # E: Module has no attribute "missing" [attr-defined]
77
env:
88
- MYPYPATH=../extras
99
files:

pytest_mypy_plugins/tests/test-simple-cases.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
- case: error_case
5858
main: |
5959
a = 1
60-
a.lower() # E: "int" has no attribute "lower"
60+
a.lower() # E: "int" has no attribute "lower" [attr-defined]
6161
6262
6363
- case: custom_mypy_config_strict_optional_true_set
@@ -87,7 +87,7 @@
8787
skip: sys.version_info < (0, 0)
8888
main: |
8989
a = 1
90-
a.lower() # E: "int" has no attribute "lower"
90+
a.lower() # E: "int" has no attribute "lower" [attr-defined]
9191
9292
- case: fail_if_message_does_not_match
9393
expect_fail: yes

0 commit comments

Comments
 (0)