99
1010from .Check import Check
1111from ci_tools .parsing import ParsedSetup
12- from ci_tools .functions import discover_targeted_packages
12+ from ci_tools .functions import pip_install
1313from ci_tools .scenario .generation import create_package_and_install
1414from ci_tools .variables import in_ci , set_envvar_defaults
1515from ci_tools .environment_exclusions import (
@@ -33,8 +33,8 @@ def register(self, subparsers: "argparse._SubParsersAction", parent_parsers: Opt
3333 p .set_defaults (func = self .run )
3434
3535 p .add_argument (
36- "--next" ,
37- default = False ,
36+ "--next" ,
37+ default = False ,
3838 help = "Next version of mypy is being tested" ,
3939 required = False
4040 )
@@ -52,27 +52,27 @@ def run(self, args: argparse.Namespace) -> int:
5252 for parsed in targeted :
5353 package_dir = parsed .folder
5454 package_name = parsed .name
55+ executable , staging_directory = self .get_executable (args .isolate , args .command , sys .executable , package_dir )
5556 print (f"Processing { package_name } for mypy check" )
56-
57- staging_area = tempfile .mkdtemp ()
5857 create_package_and_install (
59- distribution_directory = staging_area ,
58+ distribution_directory = staging_directory ,
6059 target_setup = package_dir ,
6160 skip_install = False ,
6261 cache_dir = None ,
63- work_dir = staging_area ,
62+ work_dir = staging_directory ,
6463 force_create = False ,
6564 package_type = "wheel" ,
6665 pre_download_disabled = False ,
66+ python_executable = executable
6767 )
6868
6969 # install mypy
7070 try :
7171 if (args .next ):
7272 # use latest version of mypy
73- check_call ([ sys . executable , "-m" , "pip" , "install" , "mypy" ] )
73+ pip_install ([ "mypy" ], True , executable , package_dir )
7474 else :
75- check_call ([ sys . executable , "-m" , "pip" , "install" , f"mypy=={ MYPY_VERSION } " ])
75+ pip_install ([ f"mypy=={ MYPY_VERSION } " ], True , executable , package_dir )
7676 except CalledProcessError as e :
7777 print ("Failed to install mypy:" , e )
7878 return e .returncode
@@ -89,7 +89,7 @@ def run(self, args: argparse.Namespace) -> int:
8989 top_level_module = parsed .namespace .split ("." )[0 ]
9090
9191 commands = [
92- sys . executable ,
92+ executable ,
9393 "-m" ,
9494 "mypy" ,
9595 "--python-version" ,
@@ -107,9 +107,9 @@ def run(self, args: argparse.Namespace) -> int:
107107 results .append (check_call (src_code ))
108108 logging .info ("Verified mypy, no issues found" )
109109 except CalledProcessError as src_error :
110- src_code_error = src_error
110+ src_code_error = src_error
111111 results .append (src_error .returncode )
112-
112+
113113 if not args .next and in_ci () and not is_check_enabled (package_dir , "type_check_samples" , True ):
114114 logging .info (
115115 f"Package { package_name } opts-out of mypy check on samples."
@@ -145,6 +145,5 @@ def run(self, args: argparse.Namespace) -> int:
145145 create_vnext_issue (package_dir , "mypy" )
146146 else :
147147 close_vnext_issue (package_name , "mypy" )
148-
148+
149149 return max (results ) if results else 0
150-
0 commit comments