Skip to content

Commit a30dc06

Browse files
committed
Respond to review
1 parent b115f51 commit a30dc06

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

mypy/test/testsamples.py

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,35 @@
11
"""Self check mypy package"""
22
import sys
33
import os.path
4-
from typing import List, Optional, Set
4+
from typing import List, Set
55

66
from mypy.test.helpers import Suite, run_mypy
77

88

99
class TypeshedSuite(Suite):
10-
def check_stubs(self, version: str, name: Optional[str] = None) -> None:
11-
if name is None:
12-
name = version
13-
seen = {'__builtin__', }
14-
modules = ['__builtin__']
10+
def check_stubs(self, version: str, *directories: str) -> None:
11+
if not directories:
12+
directories = (version,)
1513
for stub_type in ['stdlib', 'third_party']:
16-
stubdir = os.path.join('typeshed', stub_type, name)
17-
for f in find_files(stubdir, suffix='.pyi'):
18-
module = file_to_module(f[len(stubdir) + 1:])
19-
if module not in seen:
20-
seen.add(module)
21-
modules.extend(['-m', module])
22-
if version == "3":
23-
version = "3.4"
24-
if modules:
25-
modules.remove('__builtin__')
26-
run_mypy(['--python-version={}'.format(version)] + modules)
14+
for dir in directories:
15+
seen = {'__builtin__'} # we don't want to check __builtin__, as it causes problems
16+
modules = []
17+
stubdir = os.path.join('typeshed', stub_type, dir)
18+
for f in find_files(stubdir, suffix='.pyi'):
19+
module = file_to_module(f[len(stubdir) + 1:])
20+
if module not in seen:
21+
seen.add(module)
22+
modules.extend(['-m', module])
23+
24+
if modules:
25+
run_mypy(['--python-version={}'.format(version)] + modules)
2726

2827
def test_2(self) -> None:
29-
self.check_stubs("2.7", name="2")
30-
31-
def test_2and3_2(self) -> None:
32-
self.check_stubs("2.7", name="2and3")
33-
34-
def test_2and3_3(self) -> None:
35-
sys_ver_str = '.'.join(map(str, sys.version_info[:2]))
36-
self.check_stubs(sys_ver_str, name="2and3")
28+
self.check_stubs("2.7", "2", "2and3")
3729

3830
def test_3(self) -> None:
39-
self.check_stubs("3")
31+
sys_ver_str = '.'.join(map(str, sys.version_info[:2]))
32+
self.check_stubs(sys_ver_str, "3", "2and3")
4033

4134
def test_34(self) -> None:
4235
self.check_stubs("3.4")

0 commit comments

Comments
 (0)