Skip to content

Commit bc1da6a

Browse files
authored
Remove unused code from pytype_test.py (#9317)
1 parent c6126b5 commit bc1da6a

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

tests/pytype_test.py

+6-14
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ def main() -> None:
3333
check_subdirs_discoverable(subdir_paths)
3434
old_typeshed_home = os.environ.get(TYPESHED_HOME)
3535
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)
4038
if old_typeshed_home is None:
4139
del os.environ[TYPESHED_HOME]
4240
else:
@@ -58,7 +56,7 @@ def create_parser() -> argparse.ArgumentParser:
5856
return parser
5957

6058

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:
6260
"""Runs pytype, returning the stderr if any."""
6361
if python_version not in _LOADERS:
6462
options = pytype_config.Options.create("", parse_pyi=True, python_version=python_version)
@@ -100,17 +98,13 @@ def _get_module_name(filename: str) -> str:
10098
return ".".join(module_parts).replace(".pyi", "").replace(".__init__", "")
10199

102100

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-
107101
def check_subdirs_discoverable(subdir_paths: list[str]) -> None:
108102
for p in subdir_paths:
109103
if not os.path.isdir(p):
110104
raise SystemExit(f"Cannot find typeshed subdir at {p} (specify parent dir via --typeshed-location)")
111105

112106

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]:
114108
"""Determine all files to test, checking if it's in the exclude list and which Python versions to use.
115109
116110
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]:
137131
return filenames
138132

139133

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:
141135
bad = []
142136
errors = 0
143137
total_tests = len(files_to_test)
144138
print("Testing files with pytype...")
145139
for i, f in enumerate(files_to_test):
146140
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
150142
if stderr:
151143
if print_stderr:
152144
print("\n{stderr}")

0 commit comments

Comments
 (0)