Skip to content

Commit 9e6d5e2

Browse files
committed
!squash more
1 parent dba8a89 commit 9e6d5e2

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

libtmux/common.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@
1313
import typing as t
1414
from collections.abc import MutableMapping
1515
from distutils.version import LooseVersion
16-
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union, overload
16+
from typing import (
17+
Any,
18+
Dict,
19+
Generic,
20+
KeysView,
21+
List,
22+
Optional,
23+
TypeVar,
24+
Union,
25+
overload,
26+
)
1727

1828
from . import exc
1929
from ._compat import console_to_str, str_from_console
@@ -248,6 +258,7 @@ def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
248258
returncode = self.process.returncode
249259
except Exception as e:
250260
logger.error(f"Exception for {subprocess.list2cmdline(cmd)}: \n{e}")
261+
raise
251262

252263
self.returncode = returncode
253264

@@ -287,31 +298,38 @@ class TmuxMappingObject(MutableMapping[t.Any, t.Any]):
287298
================ ================================== ==============
288299
"""
289300
_info: t.Dict[t.Any, t.Any]
301+
formatter_prefix: str
290302

291303
def __getitem__(self, key: str) -> str:
292-
return self._info[key]
304+
item = self._info[key]
305+
assert item is not None
306+
assert isinstance(item, str)
307+
return item
293308

294309
def __setitem__(self, key: str, value: str) -> None:
295310
self._info[key] = value
296311
self.dirty = True
297312

298-
def __delitem__(self, key):
313+
def __delitem__(self, key: str) -> None:
299314
del self._info[key]
300315
self.dirty = True
301316

302-
def keys(self):
317+
def keys(self) -> KeysView[str]:
303318
"""Return list of keys."""
304319
return self._info.keys()
305320

306-
def __iter__(self):
321+
def __iter__(self) -> t.Iterator[str]:
307322
return self._info.__iter__()
308323

309324
def __len__(self) -> int:
310325
return len(self._info.keys())
311326

312327
def __getattr__(self, key: str) -> str:
313328
try:
314-
return self._info[self.formatter_prefix + key]
329+
val = self._info[self.formatter_prefix + key]
330+
assert val is not None
331+
assert isinstance(val, str)
332+
return val
315333
except KeyError:
316334
raise AttributeError(f"{self.__class__} has no property {key}")
317335

0 commit comments

Comments
 (0)