backend: fix type annotation of Backend.generate

`func(value: dict = None)` is invalid, it must be `func(value: dict |
None = None)`, or in our older syntax: `T.Optional[T.Dict] = None`
pull/13146/head
Dylan Baker 10 months ago
parent cf0fecfcef
commit f603a266ec
  1. 2
      mesonbuild/backend/backends.py
  2. 2
      mesonbuild/backend/ninjabackend.py
  3. 3
      mesonbuild/backend/nonebackend.py
  4. 2
      mesonbuild/backend/vs2010backend.py
  5. 2
      mesonbuild/backend/xcodebackend.py

@ -287,7 +287,7 @@ class Backend:
# 'vslite_ctx' is only provided when
# we expect this backend setup/generation to make use of previously captured
# compile args (as is the case when using '--genvslite').
def generate(self, capture: bool = False, vslite_ctx: dict = None) -> T.Optional[dict]:
def generate(self, capture: bool = False, vslite_ctx: T.Optional[T.Dict] = None) -> T.Optional[T.Dict]:
raise RuntimeError(f'generate is not implemented in {type(self).__name__}')
def get_target_filename(self, t: T.Union[build.Target, build.CustomTargetIndex], *, warn_multi_output: bool = True) -> str:

@ -581,7 +581,7 @@ class NinjaBackend(backends.Backend):
raise MesonException(f'Could not determine vs dep dependency prefix string. output: {stderr} {stdout}')
def generate(self, capture: bool = False, vslite_ctx: dict = None) -> T.Optional[dict]:
def generate(self, capture: bool = False, vslite_ctx: T.Optional[T.Dict] = None) -> T.Optional[T.Dict]:
if vslite_ctx:
# We don't yet have a use case where we'd expect to make use of this,
# so no harm in catching and reporting something unexpected.

@ -2,6 +2,7 @@
# Copyright 2022 The Meson development team
from __future__ import annotations
import typing as T
from .backends import Backend
from .. import mlog
@ -12,7 +13,7 @@ class NoneBackend(Backend):
name = 'none'
def generate(self, capture: bool = False, vslite_ctx: dict = None) -> None:
def generate(self, capture: bool = False, vslite_ctx: T.Optional[T.Dict] = None) -> None:
# Check for (currently) unexpected capture arg use cases -
if capture:
raise MesonBugException('We do not expect the none backend to generate with \'capture = True\'')

@ -221,7 +221,7 @@ class Vs2010Backend(backends.Backend):
def generate(self,
capture: bool = False,
vslite_ctx: dict = None) -> T.Optional[dict]:
vslite_ctx: T.Optional[T.Dict] = None) -> T.Optional[T.Dict]:
# Check for (currently) unexpected capture arg use cases -
if capture:
raise MesonBugException('We do not expect any vs backend to generate with \'capture = True\'')

@ -255,7 +255,7 @@ class XCodeBackend(backends.Backend):
result.append(os.path.join(self.environment.get_build_dir(), self.get_target_dir(l)))
return result
def generate(self, capture: bool = False, vslite_ctx: dict = None) -> None:
def generate(self, capture: bool = False, vslite_ctx: T.Optional[T.Dict] = None) -> None:
# Check for (currently) unexpected capture arg use cases -
if capture:
raise MesonBugException('We do not expect the xcode backend to generate with \'capture = True\'')

Loading…
Cancel
Save