pylint: fix false positive for missing else branch

We cover every case as if/elif/elif. mypy can handle this fine, but
pylint doesn't do control flow or type checking and thinks in the
missing else case, the variable might not be defined.

For mypy as well, doing this instance check is unnecessary as it can be
inferred. So just micro-optimize the check and allow pylint to safely
analyze the logic.

(cherry picked from commit 29a62ff794)
1.4
Eli Schwartz 9 months ago
parent 9cf3354f32
commit 2d807d5d1e
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 2
      mesonbuild/linkers/detect.py

@ -45,7 +45,7 @@ def guess_win_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
check_args = ['/logo', '--version'] check_args = ['/logo', '--version']
elif isinstance(comp_class.LINKER_PREFIX, str): elif isinstance(comp_class.LINKER_PREFIX, str):
check_args = [comp_class.LINKER_PREFIX + '/logo', comp_class.LINKER_PREFIX + '--version'] check_args = [comp_class.LINKER_PREFIX + '/logo', comp_class.LINKER_PREFIX + '--version']
elif isinstance(comp_class.LINKER_PREFIX, list): else: # list
check_args = comp_class.LINKER_PREFIX + ['/logo'] + comp_class.LINKER_PREFIX + ['--version'] check_args = comp_class.LINKER_PREFIX + ['/logo'] + comp_class.LINKER_PREFIX + ['--version']
check_args += env.coredata.get_external_link_args(for_machine, comp_class.language) check_args += env.coredata.get_external_link_args(for_machine, comp_class.language)

Loading…
Cancel
Save