diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2023-01-06 11:23:55 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2023-01-10 09:53:22 -0800 |
commit | e8a88f53205d5d9092ccd16faa5cf89af72d2951 (patch) | |
tree | 151e30f9bdd61b4fc8023dedb40de80fc97ce67f /mesonbuild | |
parent | a28545d9cbf93c4d34bd6e0ee82740459398a97f (diff) | |
download | meson-e8a88f53205d5d9092ccd16faa5cf89af72d2951.zip meson-e8a88f53205d5d9092ccd16faa5cf89af72d2951.tar.gz meson-e8a88f53205d5d9092ccd16faa5cf89af72d2951.tar.bz2 |
modules: add type annotations to the `__init__` module
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/modules/__init__.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index b63a5da..3b7c299 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -86,10 +86,13 @@ class ModuleState: return dirs_str - def find_program(self, prog: T.Union[str, T.List[str]], required: bool = True, - version_func: T.Optional[T.Callable[['ExternalProgram'], str]] = None, + def find_program(self, prog: T.Union[mesonlib.FileOrString, T.List[mesonlib.FileOrString]], + required: bool = True, + version_func: T.Optional[T.Callable[[T.Union[ExternalProgram, Executable, OverrideProgram]], str]] = None, wanted: T.Optional[str] = None, silent: bool = False, - for_machine: MachineChoice = MachineChoice.HOST) -> 'ExternalProgram': + for_machine: MachineChoice = MachineChoice.HOST) -> T.Union[ExternalProgram, Executable, OverrideProgram]: + if not isinstance(prog, list): + prog = [prog] return self._interpreter.find_program_impl(prog, required=required, version_func=version_func, wanted=wanted, silent=silent, for_machine=for_machine) @@ -117,7 +120,7 @@ class ModuleState: def dependency(self, depname: str, native: bool = False, required: bool = True, wanted: T.Optional[str] = None) -> 'Dependency': - kwargs = {'native': native, 'required': required} + kwargs: T.Dict[str, object] = {'native': native, 'required': required} if wanted: kwargs['version'] = wanted # FIXME: Even if we fix the function, mypy still can't figure out what's @@ -142,7 +145,7 @@ class ModuleState: def get_option(self, name: str, subproject: str = '', machine: MachineChoice = MachineChoice.HOST, lang: T.Optional[str] = None, - module: T.Optional[str] = None) -> T.Union[str, int, bool, 'WrapMode']: + module: T.Optional[str] = None) -> T.Union[T.List[str], str, int, bool, 'WrapMode']: return self.environment.coredata.get_option(mesonlib.OptionKey(name, subproject, machine, lang, module)) def is_user_defined_option(self, name: str, subproject: str = '', @@ -243,13 +246,11 @@ class NotFoundExtensionModule(NewExtensionModule): return False -def is_module_library(fname): +def is_module_library(fname: mesonlib.FileOrString) -> bool: ''' Check if the file is a library-like file generated by a module-specific target, such as GirTarget or TypelibTarget ''' - if hasattr(fname, 'fname'): - fname = fname.fname suffix = fname.split('.')[-1] return suffix in {'gir', 'typelib'} |