@@ -33,10 +33,8 @@ def main() -> None:
33
33
check_subdirs_discoverable (subdir_paths )
34
34
old_typeshed_home = os .environ .get (TYPESHED_HOME )
35
35
os .environ [TYPESHED_HOME ] = typeshed_location
36
- files_to_test = determine_files_to_test (typeshed_location = typeshed_location , paths = args .files or subdir_paths )
37
- run_all_tests (
38
- files_to_test = files_to_test , typeshed_location = typeshed_location , print_stderr = args .print_stderr , dry_run = args .dry_run
39
- )
36
+ files_to_test = determine_files_to_test (paths = args .files or subdir_paths )
37
+ run_all_tests (files_to_test = files_to_test , print_stderr = args .print_stderr , dry_run = args .dry_run )
40
38
if old_typeshed_home is None :
41
39
del os .environ [TYPESHED_HOME ]
42
40
else :
@@ -58,7 +56,7 @@ def create_parser() -> argparse.ArgumentParser:
58
56
return parser
59
57
60
58
61
- def run_pytype (* , filename : str , python_version : str , typeshed_location : str ) -> str | None :
59
+ def run_pytype (* , filename : str , python_version : str ) -> str | None :
62
60
"""Runs pytype, returning the stderr if any."""
63
61
if python_version not in _LOADERS :
64
62
options = pytype_config .Options .create ("" , parse_pyi = True , python_version = python_version )
@@ -100,17 +98,13 @@ def _get_module_name(filename: str) -> str:
100
98
return "." .join (module_parts ).replace (".pyi" , "" ).replace (".__init__" , "" )
101
99
102
100
103
- def _is_version (path : str , version : str ) -> bool :
104
- return any (f"{ d } { os .path .sep } { version } " in path for d in TYPESHED_SUBDIRS )
105
-
106
-
107
101
def check_subdirs_discoverable (subdir_paths : list [str ]) -> None :
108
102
for p in subdir_paths :
109
103
if not os .path .isdir (p ):
110
104
raise SystemExit (f"Cannot find typeshed subdir at { p } (specify parent dir via --typeshed-location)" )
111
105
112
106
113
- def determine_files_to_test (* , typeshed_location : str , paths : Sequence [str ]) -> list [str ]:
107
+ def determine_files_to_test (* , paths : Sequence [str ]) -> list [str ]:
114
108
"""Determine all files to test, checking if it's in the exclude list and which Python versions to use.
115
109
116
110
Returns a list of pairs of the file path and Python version as an int."""
@@ -137,16 +131,14 @@ def find_stubs_in_paths(paths: Sequence[str]) -> list[str]:
137
131
return filenames
138
132
139
133
140
- def run_all_tests (* , files_to_test : Sequence [str ], typeshed_location : str , print_stderr : bool , dry_run : bool ) -> None :
134
+ def run_all_tests (* , files_to_test : Sequence [str ], print_stderr : bool , dry_run : bool ) -> None :
141
135
bad = []
142
136
errors = 0
143
137
total_tests = len (files_to_test )
144
138
print ("Testing files with pytype..." )
145
139
for i , f in enumerate (files_to_test ):
146
140
python_version = "{0.major}.{0.minor}" .format (sys .version_info )
147
- stderr = (
148
- run_pytype (filename = f , python_version = python_version , typeshed_location = typeshed_location ) if not dry_run else None
149
- )
141
+ stderr = run_pytype (filename = f , python_version = python_version ) if not dry_run else None
150
142
if stderr :
151
143
if print_stderr :
152
144
print ("\n {stderr}" )
0 commit comments