diff --git a/build/fbcode_builder/getdeps/buildopts.py b/build/fbcode_builder/getdeps/buildopts.py index 5b731b003..90b35b7e2 100644 --- a/build/fbcode_builder/getdeps/buildopts.py +++ b/build/fbcode_builder/getdeps/buildopts.py @@ -10,6 +10,7 @@ import os import subprocess import sys import tempfile +from typing import Optional, Mapping from .copytree import containing_repo_type from .envfuncs import Env, add_path_entry @@ -18,12 +19,6 @@ from .manifest import ContextGenerator from .platform import HostType, is_windows -try: - import typing # noqa: F401 -except ImportError: - pass - - def detect_project(path): repo_type, repo_root = containing_repo_type(path) if repo_type is None: @@ -312,10 +307,9 @@ def list_win32_subst_letters(): def find_existing_win32_subst_for_path( - path, # type: str - subst_mapping, # type: typing.Mapping[str, str] -): - # type: (...) -> typing.Optional[str] + path: str, + subst_mapping: Mapping[str, str], +) -> Optional[str]: path = ntpath.normcase(ntpath.normpath(path)) for letter, target in subst_mapping.items(): if ntpath.normcase(target) == path: diff --git a/build/fbcode_builder/getdeps/py_wheel_builder.py b/build/fbcode_builder/getdeps/py_wheel_builder.py index cc783b713..77efe9ba3 100644 --- a/build/fbcode_builder/getdeps/py_wheel_builder.py +++ b/build/fbcode_builder/getdeps/py_wheel_builder.py @@ -98,9 +98,7 @@ class PythonWheelBuilder(BuilderBase): that can be used by add_fb_python_library()/add_fb_python_executable() CMake rules. """ - def _build(self, install_dirs, reconfigure): - # type: (List[str], bool) -> None - + def _build(self, install_dirs: List[str], reconfigure: bool) -> None: # When we are invoked, self.src_dir contains the unpacked wheel contents. # # Since a wheel file is just a zip file, the Fetcher code recognizes it as such @@ -169,9 +167,7 @@ class PythonWheelBuilder(BuilderBase): # Run the build self._run_cmake_build(install_dirs, reconfigure) - def _run_cmake_build(self, install_dirs, reconfigure): - # type: (List[str], bool) -> None - + def _run_cmake_build(self, install_dirs: List[str], reconfigure: bool) -> None: cmake_builder = CMakeBuilder( build_opts=self.build_opts, ctx=self.ctx, @@ -187,9 +183,7 @@ class PythonWheelBuilder(BuilderBase): ) cmake_builder.build(install_dirs=install_dirs, reconfigure=reconfigure) - def _write_cmakelists(self, path_mapping, dependencies): - # type: (List[str]) -> None - + def _write_cmakelists(self, path_mapping: List[str], dependencies) -> None: cmake_path = os.path.join(self.build_dir, "CMakeLists.txt") with open(cmake_path, "w") as f: f.write(CMAKE_HEADER.format(**self.template_format_dict)) @@ -221,9 +215,7 @@ class PythonWheelBuilder(BuilderBase): with open(output_path, "w") as f: f.write(CMAKE_CONFIG_FILE.format(**self.template_format_dict)) - def _add_sources(self, path_mapping, src_path, install_path): - # type: (List[str], str, str) -> None - + def _add_sources(self, path_mapping: List[str], src_path: str, install_path: str): s = os.lstat(src_path) if not stat.S_ISDIR(s.st_mode): path_mapping[src_path] = install_path @@ -236,9 +228,7 @@ class PythonWheelBuilder(BuilderBase): os.path.join(install_path, entry), ) - def _parse_wheel_name(self): - # type: () -> WheelNameInfo - + def _parse_wheel_name(self) -> WheelNameInfo: # The ArchiveFetcher prepends "manifest_name-", so strip that off first. wheel_name = os.path.basename(self.src_dir) prefix = self.manifest.name + "-"