Skip to content

Commit 97aff1e

Browse files
authored
Test inline mypy configuration with more stable mypy option (#138)
* Test inline mypy configuration with more stable mypy option The mypy configuration --no-strict-optional is discouraged and not much tested. It caused the test to fail with >=mypy-1.6.0. Closes #137 * Update flush_errors to match the signature of >=mypy-1.8.0
1 parent c80f1eb commit 97aff1e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

pytest_mypy_plugins/item.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ def run_mypy_typechecking(cmd_options: List[str], stdout: TextIO, stderr: TextIO
8282

8383
error_messages = []
8484

85-
def flush_errors(new_messages: List[str], serious: bool) -> None:
85+
# discard filename parameter '_'. Mypy uses it to generate
86+
# one junit-xml test entry per file with failures (--junit-format per_file)
87+
# and we don't support mypy's --junit-xml option in the first place.
88+
def flush_errors(_: str | None, new_messages: List[str], serious: bool) -> None:
8689
error_messages.extend(new_messages)
8790
f = stderr if serious else stdout
8891
try:
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Also used in `test_explicit_configs.py`
22

3-
- case: custom_mypy_config_strict_optional_true_set
3+
- case: custom_mypy_config_disallow_any_explicit_set
4+
expect_fail: yes
45
main: |
5-
from typing import Optional
6-
a: Optional[int] = None
7-
a + 1 # should not raise an error
6+
from typing import Any
7+
a: Any = None # should raise an error
88
mypy_config: |
9-
strict_optional = false
9+
disallow_any_explicit = true

0 commit comments

Comments
 (0)