diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2023-01-06 11:21:14 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2023-01-10 09:53:22 -0800 |
commit | 27df0e09f701e88c5f924ea75adb0aea236091cb (patch) | |
tree | 2fef48aea4d1adf0cae296cea81d4c8998098349 /mesonbuild | |
parent | e268d9f1378fdcf0660bb3c980e08f978eb970d1 (diff) | |
download | meson-27df0e09f701e88c5f924ea75adb0aea236091cb.zip meson-27df0e09f701e88c5f924ea75adb0aea236091cb.tar.gz meson-27df0e09f701e88c5f924ea75adb0aea236091cb.tar.bz2 |
modules/gnome: fix type annotations from `__init__`, which are wrong
Mainly thi sis that `state.find_program()` is annotated incorrectly, it
returns `ExternalProgram | Executable | OverrideProgram`, but it's
annotated to return only `ExteranlProgram`, and thus a bunch of the
annotations in the gnome module are wrong.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/modules/gnome.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index b5de7b7..b6c9aeb 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -403,7 +403,7 @@ class GnomeModule(ExtensionModule): glib_version = self._get_native_glib_version(state) glib_compile_resources = state.find_program('glib-compile-resources') - cmd: T.List[T.Union[ExternalProgram, str]] = [glib_compile_resources, '@INPUT@'] + cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [glib_compile_resources, '@INPUT@'] source_dirs = kwargs['source_dir'] dependencies = kwargs['dependencies'] @@ -493,7 +493,7 @@ class GnomeModule(ExtensionModule): raise MesonException('GResource header is installed yet export is not enabled') depfile: T.Optional[str] = None - target_cmd: T.List[T.Union[ExternalProgram, str]] + target_cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] if not mesonlib.version_compare(glib_version, gresource_dep_needed_version): # This will eventually go out of sync if dependencies are added target_cmd = cmd @@ -1232,7 +1232,7 @@ class GnomeModule(ExtensionModule): srcdir = os.path.join(state.build_to_src, state.subdir) outdir = state.subdir - cmd: T.List[T.Union[ExternalProgram, str]] = [state.find_program('glib-compile-schemas'), '--targetdir', outdir, srcdir] + cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [state.find_program('glib-compile-schemas'), '--targetdir', outdir, srcdir] if state.subdir == '': targetname = 'gsettings-compile' else: @@ -1311,7 +1311,7 @@ class GnomeModule(ExtensionModule): pot_file = os.path.join('@SOURCE_ROOT@', state.subdir, 'C', project_id + '.pot') pot_sources = [os.path.join('@SOURCE_ROOT@', state.subdir, 'C', s) for s in sources] - pot_args: T.List[T.Union['ExternalProgram', str]] = [itstool, '-o', pot_file] + pot_args: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [itstool, '-o', pot_file] pot_args.extend(pot_sources) pottarget = build.RunTarget(f'help-{project_id}-pot', pot_args, [], os.path.join(state.subdir, 'C'), state.subproject, @@ -1340,7 +1340,7 @@ class GnomeModule(ExtensionModule): targets.append(l_data) po_file = l + '.po' - po_args: T.List[T.Union['ExternalProgram', str]] = [ + po_args: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [ msgmerge, '-q', '-o', os.path.join('@SOURCE_ROOT@', l_subdir, po_file), os.path.join('@SOURCE_ROOT@', l_subdir, po_file), pot_file] @@ -1462,6 +1462,7 @@ class GnomeModule(ExtensionModule): program_name = 'gtkdoc-' + tool program = state.find_program(program_name) path = program.get_path() + assert path is not None, "This shouldn't be possible since program should be found" t_args.append(f'--{program_name}={path}') if namespace: t_args.append('--namespace=' + namespace) @@ -1596,7 +1597,7 @@ class GnomeModule(ExtensionModule): kwargs: 'GdbusCodegen') -> ModuleReturnValue: namebase = args[0] xml_files: T.List[T.Union['FileOrString', build.GeneratedTypes]] = [args[1]] if args[1] else [] - cmd: T.List[T.Union['ExternalProgram', str]] = [state.find_program('gdbus-codegen')] + cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [state.find_program('gdbus-codegen')] cmd.extend(kwargs['extra_args']) # Autocleanup supported? @@ -1914,7 +1915,7 @@ class GnomeModule(ExtensionModule): install_dir: T.Optional[T.Sequence[T.Union[str, bool]]] = None, depends: T.Optional[T.Sequence[T.Union[CustomTarget, CustomTargetIndex, BuildTarget]]] = None ) -> build.CustomTarget: - real_cmd: T.List[T.Union[str, ExternalProgram]] = [state.find_program(['glib-mkenums', 'mkenums'])] + real_cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [state.find_program(['glib-mkenums', 'mkenums'])] real_cmd.extend(cmd) _install_dir = install_dir or state.environment.coredata.get_option(mesonlib.OptionKey('includedir')) assert isinstance(_install_dir, str), 'for mypy' @@ -1958,7 +1959,7 @@ class GnomeModule(ExtensionModule): new_genmarshal = mesonlib.version_compare(self._get_native_glib_version(state), '>= 2.53.3') - cmd: T.List[T.Union['ExternalProgram', str]] = [state.find_program('glib-genmarshal')] + cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [state.find_program('glib-genmarshal')] if kwargs['prefix']: cmd.extend(['--prefix', kwargs['prefix']]) if kwargs['extra_args']: @@ -2103,7 +2104,7 @@ class GnomeModule(ExtensionModule): build_dir = os.path.join(state.environment.get_build_dir(), state.subdir) source_dir = os.path.join(state.environment.get_source_dir(), state.subdir) pkg_cmd, vapi_depends, vapi_packages, vapi_includes, packages = self._extract_vapi_packages(state, kwargs['packages']) - cmd: T.List[T.Union[str, 'ExternalProgram']] + cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] cmd = [state.find_program('vapigen'), '--quiet', f'--library={library}', f'--directory={build_dir}'] cmd.extend([f'--vapidir={d}' for d in kwargs['vapi_dirs']]) cmd.extend([f'--metadatadir={d}' for d in kwargs['metadata_dirs']]) |