9
9
10
10
from .Check import Check
11
11
from ci_tools .parsing import ParsedSetup
12
- from ci_tools .functions import discover_targeted_packages
12
+ from ci_tools .functions import pip_install
13
13
from ci_tools .scenario .generation import create_package_and_install
14
14
from ci_tools .variables import in_ci , set_envvar_defaults
15
15
from ci_tools .environment_exclusions import (
@@ -33,8 +33,8 @@ def register(self, subparsers: "argparse._SubParsersAction", parent_parsers: Opt
33
33
p .set_defaults (func = self .run )
34
34
35
35
p .add_argument (
36
- "--next" ,
37
- default = False ,
36
+ "--next" ,
37
+ default = False ,
38
38
help = "Next version of mypy is being tested" ,
39
39
required = False
40
40
)
@@ -52,27 +52,27 @@ def run(self, args: argparse.Namespace) -> int:
52
52
for parsed in targeted :
53
53
package_dir = parsed .folder
54
54
package_name = parsed .name
55
+ executable , staging_directory = self .get_executable (args .isolate , args .command , sys .executable , package_dir )
55
56
print (f"Processing { package_name } for mypy check" )
56
-
57
- staging_area = tempfile .mkdtemp ()
58
57
create_package_and_install (
59
- distribution_directory = staging_area ,
58
+ distribution_directory = staging_directory ,
60
59
target_setup = package_dir ,
61
60
skip_install = False ,
62
61
cache_dir = None ,
63
- work_dir = staging_area ,
62
+ work_dir = staging_directory ,
64
63
force_create = False ,
65
64
package_type = "wheel" ,
66
65
pre_download_disabled = False ,
66
+ python_executable = executable
67
67
)
68
68
69
69
# install mypy
70
70
try :
71
71
if (args .next ):
72
72
# use latest version of mypy
73
- check_call ([ sys . executable , "-m" , "pip" , "install" , "mypy" ] )
73
+ pip_install ([ "mypy" ], True , executable , package_dir )
74
74
else :
75
- check_call ([ sys . executable , "-m" , "pip" , "install" , f"mypy=={ MYPY_VERSION } " ])
75
+ pip_install ([ f"mypy=={ MYPY_VERSION } " ], True , executable , package_dir )
76
76
except CalledProcessError as e :
77
77
print ("Failed to install mypy:" , e )
78
78
return e .returncode
@@ -89,7 +89,7 @@ def run(self, args: argparse.Namespace) -> int:
89
89
top_level_module = parsed .namespace .split ("." )[0 ]
90
90
91
91
commands = [
92
- sys . executable ,
92
+ executable ,
93
93
"-m" ,
94
94
"mypy" ,
95
95
"--python-version" ,
@@ -107,9 +107,9 @@ def run(self, args: argparse.Namespace) -> int:
107
107
results .append (check_call (src_code ))
108
108
logging .info ("Verified mypy, no issues found" )
109
109
except CalledProcessError as src_error :
110
- src_code_error = src_error
110
+ src_code_error = src_error
111
111
results .append (src_error .returncode )
112
-
112
+
113
113
if not args .next and in_ci () and not is_check_enabled (package_dir , "type_check_samples" , True ):
114
114
logging .info (
115
115
f"Package { package_name } opts-out of mypy check on samples."
@@ -145,6 +145,5 @@ def run(self, args: argparse.Namespace) -> int:
145
145
create_vnext_issue (package_dir , "mypy" )
146
146
else :
147
147
close_vnext_issue (package_name , "mypy" )
148
-
148
+
149
149
return max (results ) if results else 0
150
-
0 commit comments