diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2023-08-10 21:19:29 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2023-08-11 13:41:03 -0400 |
commit | 90ce0841441506e3f409ab59ded1df8f2e6e7363 (patch) | |
tree | 3478769eef2620e9d7b5a41b73dd94c75b003465 /mesonbuild/dependencies | |
parent | de1cc0b02bcb1bab6977f0ab8bb3fef0cd0646dd (diff) | |
download | meson-90ce0841441506e3f409ab59ded1df8f2e6e7363.zip meson-90ce0841441506e3f409ab59ded1df8f2e6e7363.tar.gz meson-90ce0841441506e3f409ab59ded1df8f2e6e7363.tar.bz2 |
treewide: automatic rewriting of all comment-style type annotations
Performed using https://github.com/ilevkivskyi/com2ann
This has no actual effect on the codebase as type checkers (still)
support both and negligible effect on runtime performance since
__future__ annotations ameliorates that. Technically, the bytecode would
be bigger for non function-local annotations, of which we have many
either way.
So if it doesn't really matter, why do a large-scale refactor? Simple:
because people keep wanting to, but it's getting nickle-and-dimed. If
we're going to do this we might as well do it consistently in one shot,
using tooling that guarantees repeatability and correctness.
Repeat with:
```
com2ann mesonbuild/
```
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r-- | mesonbuild/dependencies/base.py | 2 | ||||
-rw-r--r-- | mesonbuild/dependencies/boost.py | 38 | ||||
-rw-r--r-- | mesonbuild/dependencies/cmake.py | 4 | ||||
-rw-r--r-- | mesonbuild/dependencies/hdf5.py | 4 | ||||
-rw-r--r-- | mesonbuild/dependencies/mpi.py | 2 |
5 files changed, 25 insertions, 25 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 72e9f44..fa94f87 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -566,7 +566,7 @@ def strip_system_includedirs(environment: 'Environment', for_machine: MachineCho return [i for i in include_args if i not in exclude] def process_method_kw(possible: T.Iterable[DependencyMethods], kwargs: T.Dict[str, T.Any]) -> T.List[DependencyMethods]: - method = kwargs.get('method', 'auto') # type: T.Union[DependencyMethods, str] + method: T.Union[DependencyMethods, str] = kwargs.get('method', 'auto') if isinstance(method, DependencyMethods): return [method] # TODO: try/except? diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py index 648c8d2..788ccbb 100644 --- a/mesonbuild/dependencies/boost.py +++ b/mesonbuild/dependencies/boost.py @@ -248,7 +248,7 @@ class BoostLibraryFile(): # Handle the boost_python naming madness. # See https://github.com/mesonbuild/meson/issues/4788 for some distro # specific naming variations. - other_tags = [] # type: T.List[str] + other_tags: T.List[str] = [] # Split the current modname into the base name and the version m_cur = BoostLibraryFile.reg_python_mod_split.match(self.mod_name) @@ -331,7 +331,7 @@ class BoostLibraryFile(): return True def get_compiler_args(self) -> T.List[str]: - args = [] # type: T.List[str] + args: T.List[str] = [] if self.mod_name in boost_libraries: libdef = boost_libraries[self.mod_name] if self.static: @@ -355,19 +355,19 @@ class BoostDependency(SystemDependency): self.debug = buildtype.startswith('debug') self.multithreading = kwargs.get('threading', 'multi') == 'multi' - self.boost_root = None # type: T.Optional[Path] + self.boost_root: T.Optional[Path] = None self.explicit_static = 'static' in kwargs # Extract and validate modules - self.modules = mesonlib.extract_as_list(kwargs, 'modules') # type: T.List[str] + self.modules: T.List[str] = mesonlib.extract_as_list(kwargs, 'modules') for i in self.modules: if not isinstance(i, str): raise DependencyException('Boost module argument is not a string.') if i.startswith('boost_'): raise DependencyException('Boost modules must be passed without the boost_ prefix') - self.modules_found = [] # type: T.List[str] - self.modules_missing = [] # type: T.List[str] + self.modules_found: T.List[str] = [] + self.modules_missing: T.List[str] = [] # Do we need threads? if 'thread' in self.modules: @@ -450,7 +450,7 @@ class BoostDependency(SystemDependency): mlog.debug(' - potential include dirs: {}'.format([x.path.as_posix() for x in inc_dirs])) # 2. Find all boost libraries - libs = [] # type: T.List[BoostLibraryFile] + libs: T.List[BoostLibraryFile] = [] for i in lib_dirs: libs = self.detect_libraries(i) if libs: @@ -471,8 +471,8 @@ class BoostDependency(SystemDependency): mlog.debug(f' - {j}') # 3. Select the libraries matching the requested modules - not_found = [] # type: T.List[str] - selected_modules = [] # type: T.List[BoostLibraryFile] + not_found: T.List[str] = [] + selected_modules: T.List[BoostLibraryFile] = [] for mod in modules: found = False for l in f_libs: @@ -485,8 +485,8 @@ class BoostDependency(SystemDependency): # log the result mlog.debug(' - found:') - comp_args = [] # type: T.List[str] - link_args = [] # type: T.List[str] + comp_args: T.List[str] = [] + link_args: T.List[str] = [] for j in selected_modules: c_args = j.get_compiler_args() l_args = j.get_link_args() @@ -524,7 +524,7 @@ class BoostDependency(SystemDependency): return False def detect_inc_dirs(self, root: Path) -> T.List[BoostIncludeDir]: - candidates = [] # type: T.List[Path] + candidates: T.List[Path] = [] inc_root = root / 'include' candidates += [root / 'boost'] @@ -555,8 +555,8 @@ class BoostDependency(SystemDependency): # No system include paths were found --> fall back to manually looking # for library dirs in root - dirs = [] # type: T.List[Path] - subdirs = [] # type: T.List[Path] + dirs: T.List[Path] = [] + subdirs: T.List[Path] = [] for i in root.iterdir(): if i.is_dir() and i.name.startswith('lib'): dirs += [i] @@ -578,7 +578,7 @@ class BoostDependency(SystemDependency): raw_list = dirs + subdirs no_arch = [x for x in raw_list if not any(y in x.name for y in arch_list_32 + arch_list_64)] - matching_arch = [] # type: T.List[Path] + matching_arch: T.List[Path] = [] if '32' in self.arch: matching_arch = [x for x in raw_list if any(y in x.name for y in arch_list_32)] elif '64' in self.arch: @@ -624,7 +624,7 @@ class BoostDependency(SystemDependency): return libs def detect_libraries(self, libdir: Path) -> T.List[BoostLibraryFile]: - libs = set() # type: T.Set[BoostLibraryFile] + libs: T.Set[BoostLibraryFile] = set() for i in libdir.iterdir(): if not i.is_file(): continue @@ -655,7 +655,7 @@ class BoostDependency(SystemDependency): self.is_found = self.run_check([boost_inc_dir], [lib_dir]) def detect_roots(self) -> None: - roots = [] # type: T.List[Path] + roots: T.List[Path] = [] # Try getting the BOOST_ROOT from a boost.pc if it exists. This primarily # allows BoostDependency to find boost from Conan. See #5438 @@ -686,7 +686,7 @@ class BoostDependency(SystemDependency): # Where boost prebuilt binaries are local_boost = Path('C:/local') - candidates = [] # type: T.List[Path] + candidates: T.List[Path] = [] if prog_files.is_dir(): candidates += [*prog_files.iterdir()] if local_boost.is_dir(): @@ -694,7 +694,7 @@ class BoostDependency(SystemDependency): roots += [x for x in candidates if x.name.lower().startswith('boost') and x.is_dir()] else: - tmp = [] # type: T.List[Path] + tmp: T.List[Path] = [] # Add some default system paths tmp += [Path('/opt/local')] diff --git a/mesonbuild/dependencies/cmake.py b/mesonbuild/dependencies/cmake.py index 8827c9a..11d3564 100644 --- a/mesonbuild/dependencies/cmake.py +++ b/mesonbuild/dependencies/cmake.py @@ -80,7 +80,7 @@ class CMakeDependency(ExternalDependency): def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None, force_use_global_compilers: bool = False) -> None: # Gather a list of all languages to support - self.language_list = [] # type: T.List[str] + self.language_list: T.List[str] = [] if language is None or force_use_global_compilers: compilers = None if kwargs.get('native', False): @@ -312,7 +312,7 @@ class CMakeDependency(ExternalDependency): return True # Check PATH - system_env = [] # type: T.List[str] + system_env: T.List[str] = [] for i in os.environ.get('PATH', '').split(os.pathsep): if i.endswith('/bin') or i.endswith('\\bin'): i = i[:-4] diff --git a/mesonbuild/dependencies/hdf5.py b/mesonbuild/dependencies/hdf5.py index 501e89d..a437e84 100644 --- a/mesonbuild/dependencies/hdf5.py +++ b/mesonbuild/dependencies/hdf5.py @@ -48,7 +48,7 @@ class HDF5PkgConfigDependency(PkgConfigDependency): return # some broken pkgconfig don't actually list the full path to the needed includes - newinc = [] # type: T.List[str] + newinc: T.List[str] = [] for arg in self.compile_args: if arg.startswith('-I'): stem = 'static' if self.static else 'shared' @@ -56,7 +56,7 @@ class HDF5PkgConfigDependency(PkgConfigDependency): newinc.append('-I' + str(Path(arg[2:]) / stem)) self.compile_args += newinc - link_args = [] # type: T.List[str] + link_args: T.List[str] = [] for larg in self.get_link_args(): lpath = Path(larg) # some pkg-config hdf5.pc (e.g. Ubuntu) don't include the commonly-used HL HDF5 libraries, diff --git a/mesonbuild/dependencies/mpi.py b/mesonbuild/dependencies/mpi.py index 240e6fd..d9a1585 100644 --- a/mesonbuild/dependencies/mpi.py +++ b/mesonbuild/dependencies/mpi.py @@ -74,7 +74,7 @@ def mpi_factory(env: 'Environment', elif language == 'fortran': tool_names = [os.environ.get('I_MPI_F90'), 'mpiifort'] - cls = IntelMPIConfigToolDependency # type: T.Type[ConfigToolDependency] + cls: T.Type[ConfigToolDependency] = IntelMPIConfigToolDependency else: # OpenMPI, which doesn't work with intel # # We try the environment variables for the tools first, but then |