Quoted slice types

This commit is contained in:
Ezri Brimhall 2025-09-04 11:08:17 -06:00
parent cc9e5614e1
commit 41f46c8bfd
Signed by: ezri
GPG Key ID: 058A78E5680C6F24
2 changed files with 8 additions and 2 deletions

View File

@ -27,6 +27,11 @@ class _typecode(str):
corresponding D-Bus container type codes at runtime.
This allows dbus-fast public interface components to pass static type analysis.
NOTE: because of how Python lists are annotated, a D-Bus struct _cannot_ be annotated as a
list in this way, only as a tuple. dbus-fast, for reasons beyond my comprehension, uses
lists for structs instead of tuples (likely because static type analysis was an anti-goal
for the library)
"""
@overload
@ -36,10 +41,10 @@ class _typecode(str):
def __getitem__(self, subitem: str | tuple[str], /) -> str: ...
@overload
def __getitem__(self, index: SupportsIndex | slice[Any, Any, Any], /) -> str: ...
def __getitem__(self, index: SupportsIndex | "slice[Any, Any, Any]", /) -> str: ...
def __getitem__(
self, subitem: int | SupportsIndex | slice[Any, Any, Any] | str | tuple[str]
self, subitem: int | SupportsIndex | "slice[Any, Any, Any]" | str | tuple[str]
) -> str:
if isinstance(subitem, str):
subitem = (subitem,)

View File

@ -267,6 +267,7 @@ class ConnectionInterface(ServiceInterface):
)
try:
await self._backend.reconnect()
self.logger.info(f"Reconnected.")
except NotImplementedError:
try:
await self._backend.temporary_disconnect()