Skip to content

Commit aad7793

Browse files
Jdwashin9Jdwashin9
authored andcommitted
no std types self completely passes
1 parent 84e9bba commit aad7793

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

mypy/test/testcheck.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import os
66
import re
77
import sys
8+
import types
9+
10+
import pytest
811

912
from mypy import build
1013
from mypy.build import Graph
@@ -24,14 +27,14 @@
2427
)
2528
from mypy.test.update_data import update_testcase_output
2629

30+
lxml: types.ModuleType | None
2731
try:
28-
import lxml # type: ignore[import-untyped]
32+
import importlib
33+
34+
lxml = importlib.import_module("lxml")
2935
except ImportError:
3036
lxml = None
3137

32-
33-
import pytest
34-
3538
# List of files that contain test case descriptions.
3639
# Includes all check-* files with the .test extension in the test-data/unit directory
3740
typecheck_files = find_test_files(pattern="check-*.test")

mypy/test/testcmdline.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import re
1111
import subprocess
1212
import sys
13+
import types
1314

1415
from mypy.test.config import PREFIX, test_temp_dir
1516
from mypy.test.data import DataDrivenTestCase, DataSuite
@@ -19,11 +20,15 @@
1920
normalize_error_messages,
2021
)
2122

23+
lxml: types.ModuleType | None
2224
try:
23-
import lxml
25+
import importlib
26+
27+
lxml = importlib.import_module("lxml")
2428
except ImportError:
2529
lxml = None
2630

31+
2732
import pytest
2833

2934
# Path to Python 3 interpreter
@@ -38,7 +43,7 @@ class PythonCmdlineSuite(DataSuite):
3843
native_sep = True
3944

4045
def run_case(self, testcase: DataDrivenTestCase) -> None:
41-
if lxml is None and os.path.basename(testcase.file) == "reports.test":
46+
if os.path.basename(testcase.file) == "reports.test" and lxml is None:
4247
pytest.skip("Cannot import lxml. Is it installed?")
4348
for step in [1] + sorted(testcase.output2):
4449
test_python_cmdline(testcase, step)

mypy/test/testreports.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
from __future__ import annotations
44

55
import textwrap
6+
import types
67

78
from mypy.report import CoberturaPackage, get_line_rate
89
from mypy.test.helpers import Suite, assert_equal
910

11+
lxml: types.ModuleType | None
1012
try:
11-
import lxml
13+
import importlib
14+
15+
lxml = importlib.import_module("lxml")
1216
except ImportError:
1317
lxml = None
1418

mypy/test_decorator_suggestion.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Callable, ParamSpec, TypeVar
1+
from typing import Callable, TypeVar
2+
from typing_extensions import ParamSpec
23

34
R = TypeVar("R")
45
P = ParamSpec("P")
@@ -9,5 +10,5 @@ def dec(f: Callable[P, R]) -> Callable[P, R]:
910

1011

1112
@dec
12-
def f():
13+
def f() -> None:
1314
print("hello world")

0 commit comments

Comments
 (0)