33import platform
44import shutil
55import sys
6- from typing import List , Optional
6+ from typing import Optional
77import xml .etree .ElementTree as xmlTree
88from argparse import ArgumentParser , ArgumentTypeError , Namespace
99from datetime import datetime
@@ -53,7 +53,7 @@ def is_running_as_admin(parsed_args: Namespace) -> bool:
5353 if is_windows (parsed_args ):
5454 import ctypes
5555 return ctypes .windll .shell32 .IsUserAnAdmin ()
56- return os .getuid () == 0 # type: ignore We know that os.getuid() is a method on Unix-like systems, ignore the pylance unknown type error for getuid.
56+ return os .getuid () == 0
5757
5858def kill_dotnet_processes (parsed_args : Namespace ):
5959 if not parsed_args .kill_dotnet_processes :
@@ -72,10 +72,10 @@ def enum_name_to_enum(enum_type: EnumMeta, enum_name: str):
7272 except KeyError as exc :
7373 raise ArgumentTypeError (f"Invalid run type name { enum_name } ." ) from exc
7474
75- def enum_name_list_to_enum_list (enum_type : EnumMeta , enum_name_list : List [str ]):
75+ def enum_name_list_to_enum_list (enum_type : EnumMeta , enum_name_list : list [str ]):
7676 return [enum_name_to_enum (enum_type , enum_name ) for enum_name in enum_name_list ]
7777
78- def check_for_runtype_specified (parsed_args : Namespace , run_types_to_check : List [RunType ]) -> bool :
78+ def check_for_runtype_specified (parsed_args : Namespace , run_types_to_check : list [RunType ]) -> bool :
7979 for run_type in run_types_to_check :
8080 if run_type .name in parsed_args .run_type_names :
8181 return True
@@ -93,7 +93,7 @@ def copy_directory_contents(src_dir: str, dest_dir: str):
9393 shutil .copy2 (os .path .join (src_dirpath , src_filename ), dest_dirpath )
9494
9595# Builds libs and corerun by default
96- def build_runtime_dependency (parsed_args : Namespace , repo_path : str , subset : str = "clr+libs" , configuration : str = "Release" , os_override = "" , arch_override = "" , additional_args : Optional [List [str ]] = None ):
96+ def build_runtime_dependency (parsed_args : Namespace , repo_path : str , subset : str = "clr+libs" , configuration : str = "Release" , os_override : str = "" , arch_override : str = "" , additional_args : Optional [list [str ]] = None ):
9797 if additional_args is None :
9898 additional_args = []
9999
@@ -117,13 +117,13 @@ def build_runtime_dependency(parsed_args: Namespace, repo_path: str, subset: str
117117 ] + additional_args
118118 RunCommand (build_libs_and_corerun_command , verbose = True ).run (os .path .join (repo_path , "eng" ))
119119
120- def run_runtime_dotnet (repo_path : str , args : Optional [List [str ]] = None ):
120+ def run_runtime_dotnet (repo_path : str , args : Optional [list [str ]] = None ):
121121 if args is None :
122122 args = []
123123 dotnet_command = ["./dotnet.sh" ] + args
124124 RunCommand (dotnet_command , verbose = True ).run (repo_path )
125125
126- def generate_layout (parsed_args : Namespace , repo_path : str , additional_args : Optional [List [str ]] = None ):
126+ def generate_layout (parsed_args : Namespace , repo_path : str , additional_args : Optional [list [str ]] = None ):
127127 if additional_args is None :
128128 additional_args = []
129129
@@ -264,10 +264,10 @@ def generate_all_runtype_dependencies(parsed_args: Namespace, repo_path: str, co
264264
265265 getLogger ().info ("Finished generating dependencies for %s run types in %s and stored in %s." , ' ' .join (map (str , parsed_args .run_type_names )), repo_path , parsed_args .artifact_storage_path )
266266
267- def generate_combined_benchmark_ci_args (parsed_args : Namespace , specific_run_type : RunType , all_commits : List [str ]) -> List [str ]:
267+ def generate_combined_benchmark_ci_args (parsed_args : Namespace , specific_run_type : RunType , all_commits : list [str ]) -> list [str ]:
268268 getLogger ().info ("Generating benchmark_ci.py arguments for %s run type using artifacts in %s." , specific_run_type .name , parsed_args .artifact_storage_path )
269269 bdn_args_unescaped : list [str ] = []
270- benchmark_ci_args = [
270+ benchmark_ci_args : list [ str ] = [
271271 '--architecture' , parsed_args .architecture ,
272272 '--frameworks' , parsed_args .framework ,
273273 '--dotnet-path' , parsed_args .dotnet_dir_path ,
@@ -330,10 +330,10 @@ def generate_combined_benchmark_ci_args(parsed_args: Namespace, specific_run_typ
330330 getLogger ().info ("Finished generating benchmark_ci.py arguments for %s run type using artifacts in %s." , specific_run_type .name , parsed_args .artifact_storage_path )
331331 return benchmark_ci_args
332332
333- def generate_single_benchmark_ci_args (parsed_args : Namespace , specific_run_type : RunType , commit : str ) -> List [str ]:
333+ def generate_single_benchmark_ci_args (parsed_args : Namespace , specific_run_type : RunType , commit : str ) -> list [str ]:
334334 getLogger ().info ("Generating benchmark_ci.py arguments for %s run type using artifacts in %s." , specific_run_type .name , parsed_args .artifact_storage_path )
335335 bdn_args_unescaped : list [str ] = []
336- benchmark_ci_args = [
336+ benchmark_ci_args : list [ str ] = [
337337 '--architecture' , parsed_args .architecture ,
338338 '--frameworks' , parsed_args .framework ,
339339 '--csproj' , parsed_args .csproj ,
@@ -445,7 +445,7 @@ def generate_artifacts_for_commit(parsed_args: Namespace, repo_url: str, repo_di
445445 getLogger ().info ("Running for %s at %s." , repo_path , commit )
446446
447447 if not os .path .exists (repo_path ):
448- repo = Repo .clone_from (repo_url , repo_path ) # type: ignore 'Type of "clone_from" is partially unknown', we know it is a method and returns a Repo
448+ repo = Repo .clone_from (repo_url , repo_path )
449449 repo .git .checkout (commit , '-f' )
450450 repo .git .show ('HEAD' )
451451 else :
@@ -458,7 +458,7 @@ def generate_artifacts_for_commit(parsed_args: Namespace, repo_url: str, repo_di
458458 generate_all_runtype_dependencies (parsed_args , repo_path , commit , (is_local and not parsed_args .skip_local_rebuild ) or parsed_args .rebuild_artifacts )
459459
460460# Run tests on the local machine
461- def run_benchmarks (parsed_args : Namespace , commits : List [str ]) -> None :
461+ def run_benchmarks (parsed_args : Namespace , commits : list [str ]) -> None :
462462 # Generate the correct benchmarks_ci.py arguments for the run type
463463 for run_type_meta in enum_name_list_to_enum_list (RunType , parsed_args .run_type_names ):
464464 # Run the benchmarks_ci.py test and save results
@@ -505,7 +505,7 @@ def check_references_exist_and_add_branch_commits(repo_url: str, references: lis
505505 repo_combined_path = os .path .join (repo_storage_path , repo_dir )
506506 if not os .path .exists (repo_combined_path ):
507507 getLogger ().debug ("Cloning %s to %s." , repo_url , repo_combined_path )
508- repo = Repo .clone_from (repo_url , repo_combined_path ) # type: ignore 'Type of "clone_from" is partially unknown', we know it is a method and returns a Repo
508+ repo = Repo .clone_from (repo_url , repo_combined_path )
509509 else :
510510 repo = Repo (repo_combined_path )
511511 repo .remotes .origin .fetch ()
@@ -564,11 +564,12 @@ def get_default_os():
564564 else :
565565 raise NotImplementedError (f"Unsupported operating system: { system } ." )
566566
567- def __main (args : List [str ]):
567+ def __main (args : list [str ]):
568568 # Define the ArgumentParser
569569 parser = ArgumentParser (description = 'Run local benchmarks for the Performance repo.' , conflict_handler = 'resolve' )
570570 add_arguments (parser )
571571 parsed_args = parser .parse_args (args )
572+ assert isinstance (parsed_args .artifact_storage_path , str )
572573 parsed_args .dotnet_dir_path = os .path .join (parsed_args .artifact_storage_path , "dotnet" )
573574
574575 setup_loggers (verbose = parsed_args .verbose )
@@ -587,9 +588,9 @@ def __main(args: List[str]):
587588
588589 # If list cached builds is specified, list the cached builds and exit
589590 if parsed_args .list_cached_builds :
590- for folder in os .listdir (parsed_args .artifact_storage_path ): # type: ignore warning about folder type being unknown, we know it is a string
591+ for folder in os .listdir (parsed_args .artifact_storage_path ):
591592 if any (run_type .name in folder for run_type in RunType ):
592- getLogger ().info (folder ) # type: ignore We know folder is a string
593+ getLogger ().info (folder )
593594 return
594595
595596 # Check to make sure we have something specified to test
0 commit comments