fix a few miscellaneous implicit-optional typing issues

pull/12027/head
Eli Schwartz 1 year ago
parent 3a4b874ec0
commit a7a3563c0d
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 2
      mesonbuild/mintro.py
  2. 8
      mesonbuild/msetup.py

@ -503,7 +503,7 @@ def list_projinfo_from_source(intr: IntrospectionInterpreter) -> T.Dict[str, T.U
intr.project_data['subproject_dir'] = intr.subproject_dir
return intr.project_data
def print_results(options: argparse.Namespace, results: T.Sequence[T.Tuple[str, T.Union[dict, T.List[T.Any]]]], indent: int) -> int:
def print_results(options: argparse.Namespace, results: T.Sequence[T.Tuple[str, T.Union[dict, T.List[T.Any]]]], indent: T.Optional[int]) -> int:
if not results and not options.force_dict:
print('No command specified')
return 1

@ -102,7 +102,7 @@ class MesonApp:
fname = os.path.join(dirname, environment.build_filename)
return os.path.exists(fname)
def validate_core_dirs(self, dir1: str, dir2: str) -> T.Tuple[str, str]:
def validate_core_dirs(self, dir1: T.Optional[str], dir2: T.Optional[str]) -> T.Tuple[str, str]:
invalid_msg_prefix = f'Neither source directory {dir1!r} nor build directory {dir2!r}'
if dir1 is None:
if dir2 is None:
@ -144,7 +144,7 @@ class MesonApp:
with open(os.path.join(build_dir, '.hgignore'), 'w', encoding='utf-8') as ofile:
ofile.write(hg_ignore_file)
def validate_dirs(self, dir1: str, dir2: str, reconfigure: bool, wipe: bool) -> T.Tuple[str, str]:
def validate_dirs(self, dir1: T.Optional[str], dir2: T.Optional[str], reconfigure: bool, wipe: bool) -> T.Tuple[str, str]:
(src_dir, build_dir) = self.validate_core_dirs(dir1, dir2)
if Path(build_dir) in Path(src_dir).parents:
raise MesonException(f'Build directory {build_dir} cannot be a parent of source directory {src_dir}')
@ -174,7 +174,7 @@ class MesonApp:
return src_dir, build_dir
# See class Backend's 'generate' for comments on capture args and returned dictionary.
def generate(self, capture: bool = False, vslite_ctx: dict = None) -> T.Optional[dict]:
def generate(self, capture: bool = False, vslite_ctx: T.Optional[dict] = None) -> T.Optional[dict]:
env = environment.Environment(self.source_dir, self.build_dir, self.options)
mlog.initialize(env.get_log_dir(), self.options.fatal_warnings)
if self.options.profile:
@ -182,7 +182,7 @@ class MesonApp:
with mesonlib.BuildDirLock(self.build_dir):
return self._generate(env, capture, vslite_ctx)
def _generate(self, env: environment.Environment, capture: bool, vslite_ctx: dict) -> T.Optional[dict]:
def _generate(self, env: environment.Environment, capture: bool, vslite_ctx: T.Optional[dict]) -> T.Optional[dict]:
# Get all user defined options, including options that have been defined
# during a previous invocation or using meson configure.
user_defined_options = argparse.Namespace(**vars(self.options))

Loading…
Cancel
Save