Skip to content

Commit

Permalink
backend: fix type annotation of Backend.generate
Browse files Browse the repository at this point in the history
`func(value: dict = None)` is invalid, it must be `func(value: dict |
None = None)`, or in our older syntax: `T.Optional[T.Dict] = None`
  • Loading branch information
dcbaker committed Apr 23, 2024
1 parent 5708a8b commit 858e6ba
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mesonbuild/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def __init__(self, build: T.Optional[build.Build], interpreter: T.Optional['Inte
# '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:
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def detect_prefix(out):

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.
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/backend/nonebackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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\'')
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/backend/vs2010backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def generate_custom_generator_commands(self, target, parent_node):

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\'')
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/backend/xcodebackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def determine_swift_dep_dirs(self, target: build.BuildTarget) -> T.List[str]:
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\'')
Expand Down

0 comments on commit 858e6ba

Please sign in to comment.