@@ -109,9 +109,7 @@ def run_command(self, cmd: str) -> str:
109
109
110
110
if proc .returncode != 0 :
111
111
self .print (f"ERROR: command returned { proc .returncode } " )
112
- raise Exception (
113
- f"Command failed ({ proc .returncode } ): { cmd !r} , output was:\n { output } "
114
- )
112
+ raise Exception (f"Command failed ({ proc .returncode } ): { cmd !r} , output was:\n { output } " )
115
113
116
114
return output .strip ()
117
115
@@ -318,9 +316,7 @@ def run_with_coverage(self, env: Env, cov_ver: Coverage) -> float:
318
316
with self .tweak_coverage_settings (cov_ver .tweaks ):
319
317
self .pre_check (env ) # NOTE: Not properly factored, and only used from here.
320
318
duration = self .run_tox (env , env .pyver .toxenv , "--skip-pkg-install" )
321
- self .post_check (
322
- env
323
- ) # NOTE: Not properly factored, and only used from here.
319
+ self .post_check (env ) # NOTE: Not properly factored, and only used from here.
324
320
return duration
325
321
326
322
@@ -333,9 +329,7 @@ def run_with_coverage(self, env: Env, cov_ver: Coverage) -> float:
333
329
raise Exception ("This doesn't work because options changed to tweaks" )
334
330
covenv = env .pyver .toxenv + "-cov" # type: ignore[unreachable]
335
331
self .run_tox (env , covenv , "--notest" )
336
- env .shell .run_command (
337
- f".tox/{ covenv } /bin/python -m pip install { cov_ver .pip_args } "
338
- )
332
+ env .shell .run_command (f".tox/{ covenv } /bin/python -m pip install { cov_ver .pip_args } " )
339
333
if cov_ver .tweaks :
340
334
replace = ("# reference: https" , f"[run]\n { cov_ver .tweaks } \n #" )
341
335
else :
@@ -499,9 +493,7 @@ def run_with_coverage(self, env: Env, cov_ver: Coverage) -> float:
499
493
)
500
494
with self .tweak_coverage_settings (cov_ver .tweaks ):
501
495
self .pre_check (env ) # NOTE: Not properly factored, and only used here.
502
- duration = self .run_tox (
503
- env , env .pyver .toxenv , "--skip-pkg-install -- --cov"
504
- )
496
+ duration = self .run_tox (env , env .pyver .toxenv , "--skip-pkg-install -- --cov" )
505
497
self .post_check (env ) # NOTE: Not properly factored, and only used here.
506
498
return duration
507
499
@@ -542,9 +534,7 @@ def run_no_coverage(self, env: Env) -> float:
542
534
543
535
def run_with_coverage (self , env : Env , cov_ver : Coverage ) -> float :
544
536
env .shell .run_command (f"{ env .python } -m pip install { cov_ver .pip_args } " )
545
- env .shell .run_command (
546
- f"{ env .python } -m coverage run -m unittest tests.test_suite"
547
- )
537
+ env .shell .run_command (f"{ env .python } -m coverage run -m unittest tests.test_suite" )
548
538
duration = env .shell .last_duration
549
539
report = env .shell .run_command (f"{ env .python } -m coverage report --precision=6" )
550
540
print ("Results:" , report .splitlines ()[- 1 ])
@@ -598,19 +588,21 @@ def run_with_coverage(self, env: Env, cov_ver: Coverage) -> float:
598
588
class ProjectMypy (ToxProject ):
599
589
git_url = "https://github.com/python/mypy"
600
590
601
- SLOW_TESTS = " or " .join ([
602
- "PythonCmdline" ,
603
- "PEP561Suite" ,
604
- "PythonEvaluation" ,
605
- "testdaemon" ,
606
- "StubgenCmdLine" ,
607
- "StubgenPythonSuite" ,
608
- "TestRun" ,
609
- "TestRunMultiFile" ,
610
- "TestExternal" ,
611
- "TestCommandLine" ,
612
- "ErrorStreamSuite" ,
613
- ])
591
+ SLOW_TESTS = " or " .join (
592
+ [
593
+ "PythonCmdline" ,
594
+ "PEP561Suite" ,
595
+ "PythonEvaluation" ,
596
+ "testdaemon" ,
597
+ "StubgenCmdLine" ,
598
+ "StubgenPythonSuite" ,
599
+ "TestRun" ,
600
+ "TestRunMultiFile" ,
601
+ "TestExternal" ,
602
+ "TestCommandLine" ,
603
+ "ErrorStreamSuite" ,
604
+ ]
605
+ )
614
606
615
607
FAST = f"-k 'not ({ SLOW_TESTS } )'"
616
608
@@ -713,9 +705,7 @@ def tweak_toml_coverage_settings(toml_file: str, tweaks: TweaksType) -> Iterator
713
705
class AdHocProject (ProjectToTest ):
714
706
"""A standalone program to run locally."""
715
707
716
- def __init__ (
717
- self , python_file : str , cur_dir : str | None = None , pip_args : str = ""
718
- ):
708
+ def __init__ (self , python_file : str , cur_dir : str | None = None , pip_args : str = "" ):
719
709
super ().__init__ ()
720
710
self .python_file = Path (python_file )
721
711
if not self .python_file .exists ():
@@ -821,9 +811,7 @@ def __init__(self, slug: str = "nocov"):
821
811
class CoveragePR (Coverage ):
822
812
"""A version of coverage.py from a pull request."""
823
813
824
- def __init__ (
825
- self , number : int , tweaks : TweaksType = None , env_vars : Env_VarsType = None
826
- ):
814
+ def __init__ (self , number : int , tweaks : TweaksType = None , env_vars : Env_VarsType = None ):
827
815
url = f"https://github.com/nedbat/coveragepy.git@refs/pull/{ number } /merge"
828
816
url_must_exist (url )
829
817
super ().__init__ (
@@ -837,9 +825,7 @@ def __init__(
837
825
class CoverageCommit (Coverage ):
838
826
"""A version of coverage.py from a specific commit."""
839
827
840
- def __init__ (
841
- self , sha : str , tweaks : TweaksType = None , env_vars : Env_VarsType = None
842
- ):
828
+ def __init__ (self , sha : str , tweaks : TweaksType = None , env_vars : Env_VarsType = None ):
843
829
url = f"https://github.com/nedbat/coveragepy.git@{ sha } "
844
830
url_must_exist (url )
845
831
super ().__init__ (
@@ -915,18 +901,11 @@ def load_results(self) -> dict[ResultKey, list[float]]:
915
901
if self .results_file .exists ():
916
902
with self .results_file .open ("r" , encoding = "utf-8" ) as f :
917
903
data : dict [str , list [float ]] = json .load (f )
918
- return {
919
- (k .split ()[0 ], k .split ()[1 ], k .split ()[2 ]): v for k , v in data .items ()
920
- }
904
+ return {(k .split ()[0 ], k .split ()[1 ], k .split ()[2 ]): v for k , v in data .items ()}
921
905
return {}
922
906
923
907
def run (self , num_runs : int = 3 ) -> None :
924
- total_runs = (
925
- len (self .projects )
926
- * len (self .py_versions )
927
- * len (self .cov_versions )
928
- * num_runs
929
- )
908
+ total_runs = len (self .projects ) * len (self .py_versions ) * len (self .cov_versions ) * num_runs
930
909
total_run_nums = iter (itertools .count (start = 1 ))
931
910
932
911
all_runs = []
@@ -962,10 +941,7 @@ def run(self, num_runs: int = 3) -> None:
962
941
for proj , pyver , cov_ver , env in all_runs :
963
942
result_key = (proj .slug , pyver .slug , cov_ver .slug )
964
943
total_run_num = next (total_run_nums )
965
- if (
966
- result_key in self .result_data
967
- and len (self .result_data [result_key ]) >= num_runs
968
- ):
944
+ if result_key in self .result_data and len (self .result_data [result_key ]) >= num_runs :
969
945
print (f"Skipping { result_key } as results already exist." )
970
946
continue
971
947
@@ -1100,9 +1076,7 @@ def run_experiment(
1100
1076
if any (rslug not in slugs for rslug in ratio_slugs ):
1101
1077
raise Exception (f"Ratio slug doesn't match a slug: { ratio_slugs } , { slugs } " )
1102
1078
if set (rows + [column ]) != set (DIMENSION_NAMES ):
1103
- raise Exception (
1104
- f"All of these must be in rows or column: { ', ' .join (DIMENSION_NAMES )} "
1105
- )
1079
+ raise Exception (f"All of these must be in rows or column: { ', ' .join (DIMENSION_NAMES )} " )
1106
1080
1107
1081
print (f"Removing and re-making { PERF_DIR } " )
1108
1082
remake (PERF_DIR )
0 commit comments