diff options
author | John Ericson <git@JohnEricson.me> | 2019-02-25 02:45:20 -0500 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-05-02 10:58:23 -0700 |
commit | 4c2617a9c6fd02e3f8831b7de8755380ac4bcb16 (patch) | |
tree | 0214fa8f65cd2b9ef66c88c588401907e868ed9f /mesonbuild/mesonlib.py | |
parent | a15a8b7e246be448e79ba20742e713e39807bd00 (diff) | |
download | meson-4c2617a9c6fd02e3f8831b7de8755380ac4bcb16.zip meson-4c2617a9c6fd02e3f8831b7de8755380ac4bcb16.tar.gz meson-4c2617a9c6fd02e3f8831b7de8755380ac4bcb16.tar.bz2 |
Add some type annotations and fix lints
Some things, like `method[...](...)` or `x: ... = ...` python 3.5
doesn't support, so I made a comment instead with the intention that it
can someday be made into a real annotation.
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r-- | mesonbuild/mesonlib.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index e389fb1..1e776e4 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -323,22 +323,20 @@ class MachineChoice(OrderedEnum): HOST = 1 TARGET = 2 -_T = typing.TypeVar('_T') - class PerMachine(typing.Generic[_T]): - def __init__(self, build: typing.Optional[_T], host: typing.Optional[_T], target: typing.Optional[_T]): + def __init__(self, build: _T, host: _T, target: _T): self.build = build self.host = host self.target = target - def __getitem__(self, machine: MachineChoice) -> typing.Optional[_T]: + def __getitem__(self, machine: MachineChoice) -> _T: return { MachineChoice.BUILD: self.build, MachineChoice.HOST: self.host, MachineChoice.TARGET: self.target }[machine] - def __setitem__(self, machine: MachineChoice, val: typing.Optional[_T]) -> None: + def __setitem__(self, machine: MachineChoice, val: _T) -> None: key = { MachineChoice.BUILD: 'build', MachineChoice.HOST: 'host', |