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.
pull/11274/head
Dylan Baker 2 years ago
parent e268d9f137
commit 27df0e09f7
  1. 19
      mesonbuild/modules/gnome.py

@ -403,7 +403,7 @@ class GnomeModule(ExtensionModule):
glib_version = self._get_native_glib_version(state) glib_version = self._get_native_glib_version(state)
glib_compile_resources = state.find_program('glib-compile-resources') 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'] source_dirs = kwargs['source_dir']
dependencies = kwargs['dependencies'] dependencies = kwargs['dependencies']
@ -493,7 +493,7 @@ class GnomeModule(ExtensionModule):
raise MesonException('GResource header is installed yet export is not enabled') raise MesonException('GResource header is installed yet export is not enabled')
depfile: T.Optional[str] = None 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): if not mesonlib.version_compare(glib_version, gresource_dep_needed_version):
# This will eventually go out of sync if dependencies are added # This will eventually go out of sync if dependencies are added
target_cmd = cmd target_cmd = cmd
@ -1232,7 +1232,7 @@ class GnomeModule(ExtensionModule):
srcdir = os.path.join(state.build_to_src, state.subdir) srcdir = os.path.join(state.build_to_src, state.subdir)
outdir = 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 == '': if state.subdir == '':
targetname = 'gsettings-compile' targetname = 'gsettings-compile'
else: else:
@ -1311,7 +1311,7 @@ class GnomeModule(ExtensionModule):
pot_file = os.path.join('@SOURCE_ROOT@', state.subdir, 'C', project_id + '.pot') 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_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) pot_args.extend(pot_sources)
pottarget = build.RunTarget(f'help-{project_id}-pot', pot_args, [], pottarget = build.RunTarget(f'help-{project_id}-pot', pot_args, [],
os.path.join(state.subdir, 'C'), state.subproject, os.path.join(state.subdir, 'C'), state.subproject,
@ -1340,7 +1340,7 @@ class GnomeModule(ExtensionModule):
targets.append(l_data) targets.append(l_data)
po_file = l + '.po' 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', msgmerge, '-q', '-o',
os.path.join('@SOURCE_ROOT@', l_subdir, po_file), os.path.join('@SOURCE_ROOT@', l_subdir, po_file),
os.path.join('@SOURCE_ROOT@', l_subdir, po_file), pot_file] os.path.join('@SOURCE_ROOT@', l_subdir, po_file), pot_file]
@ -1462,6 +1462,7 @@ class GnomeModule(ExtensionModule):
program_name = 'gtkdoc-' + tool program_name = 'gtkdoc-' + tool
program = state.find_program(program_name) program = state.find_program(program_name)
path = program.get_path() 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}') t_args.append(f'--{program_name}={path}')
if namespace: if namespace:
t_args.append('--namespace=' + namespace) t_args.append('--namespace=' + namespace)
@ -1596,7 +1597,7 @@ class GnomeModule(ExtensionModule):
kwargs: 'GdbusCodegen') -> ModuleReturnValue: kwargs: 'GdbusCodegen') -> ModuleReturnValue:
namebase = args[0] namebase = args[0]
xml_files: T.List[T.Union['FileOrString', build.GeneratedTypes]] = [args[1]] if args[1] else [] 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']) cmd.extend(kwargs['extra_args'])
# Autocleanup supported? # Autocleanup supported?
@ -1914,7 +1915,7 @@ class GnomeModule(ExtensionModule):
install_dir: T.Optional[T.Sequence[T.Union[str, bool]]] = None, install_dir: T.Optional[T.Sequence[T.Union[str, bool]]] = None,
depends: T.Optional[T.Sequence[T.Union[CustomTarget, CustomTargetIndex, BuildTarget]]] = None depends: T.Optional[T.Sequence[T.Union[CustomTarget, CustomTargetIndex, BuildTarget]]] = None
) -> build.CustomTarget: ) -> 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) real_cmd.extend(cmd)
_install_dir = install_dir or state.environment.coredata.get_option(mesonlib.OptionKey('includedir')) _install_dir = install_dir or state.environment.coredata.get_option(mesonlib.OptionKey('includedir'))
assert isinstance(_install_dir, str), 'for mypy' 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') 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']: if kwargs['prefix']:
cmd.extend(['--prefix', kwargs['prefix']]) cmd.extend(['--prefix', kwargs['prefix']])
if kwargs['extra_args']: if kwargs['extra_args']:
@ -2103,7 +2104,7 @@ class GnomeModule(ExtensionModule):
build_dir = os.path.join(state.environment.get_build_dir(), state.subdir) build_dir = os.path.join(state.environment.get_build_dir(), state.subdir)
source_dir = os.path.join(state.environment.get_source_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']) 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 = [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'--vapidir={d}' for d in kwargs['vapi_dirs']])
cmd.extend([f'--metadatadir={d}' for d in kwargs['metadata_dirs']]) cmd.extend([f'--metadatadir={d}' for d in kwargs['metadata_dirs']])

Loading…
Cancel
Save