fix: more cython3 optional fixes (#219)
This commit is contained in:
parent
df7f57b392
commit
5b6cbc560e
@ -104,7 +104,7 @@ class _MessageWriter:
|
||||
"""Call the write callback without removing the writer."""
|
||||
self.write_callback(remove_writer=False)
|
||||
|
||||
def schedule_write(self, msg: Message = None, future=None) -> None:
|
||||
def schedule_write(self, msg: Optional[Message] = None, future=None) -> None:
|
||||
queue_is_empty = not self.messages
|
||||
if msg is not None:
|
||||
self.buffer_message(msg, future)
|
||||
@ -158,9 +158,9 @@ class MessageBus(BaseMessageBus):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
bus_address: str = None,
|
||||
bus_address: Optional[str] = None,
|
||||
bus_type: BusType = BusType.SESSION,
|
||||
auth: Authenticator = None,
|
||||
auth: Optional[Authenticator] = None,
|
||||
negotiate_unix_fd: bool = False,
|
||||
) -> None:
|
||||
super().__init__(bus_address, bus_type, ProxyObject, negotiate_unix_fd)
|
||||
|
||||
@ -11,7 +11,7 @@ def build_message_reader(
|
||||
process: Callable[[Message], None],
|
||||
finalize: Callable[[Optional[Exception]], None],
|
||||
negotiate_unix_fd: bool,
|
||||
) -> None:
|
||||
) -> Callable[[], None]:
|
||||
"""Build a callable that reads messages from the unmarshaller and passes them to the process function."""
|
||||
unmarshaller = Unmarshaller(None, sock, negotiate_unix_fd)
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ class AuthExternal(Authenticator):
|
||||
:sealso: https://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
|
||||
"""
|
||||
|
||||
def __init__(self, uid: int = None) -> None:
|
||||
def __init__(self, uid: Optional[int] = None) -> None:
|
||||
self.negotiate_unix_fd: bool = False
|
||||
self.negotiating_fds: bool = False
|
||||
self.uid: Optional[int] = uid
|
||||
|
||||
@ -159,9 +159,9 @@ class MessageBus(BaseMessageBus):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
bus_address: str = None,
|
||||
bus_address: Optional[str] = None,
|
||||
bus_type: BusType = BusType.SESSION,
|
||||
auth: Authenticator = None,
|
||||
auth: Optional[Authenticator] = None,
|
||||
):
|
||||
if _import_error:
|
||||
raise _import_error
|
||||
@ -185,7 +185,10 @@ class MessageBus(BaseMessageBus):
|
||||
)
|
||||
|
||||
def connect(
|
||||
self, connect_notify: Callable[["MessageBus", Optional[Exception]], None] = None
|
||||
self,
|
||||
connect_notify: Optional[
|
||||
Callable[["MessageBus", Optional[Exception]], None]
|
||||
] = None,
|
||||
):
|
||||
"""Connect this message bus to the DBus daemon.
|
||||
|
||||
@ -272,7 +275,9 @@ class MessageBus(BaseMessageBus):
|
||||
def call(
|
||||
self,
|
||||
msg: Message,
|
||||
reply_notify: Callable[[Optional[Message], Optional[Exception]], None] = None,
|
||||
reply_notify: Optional[
|
||||
Callable[[Optional[Message], Optional[Exception]], None]
|
||||
] = None,
|
||||
):
|
||||
"""Send a method call and asynchronously wait for a reply from the DBus
|
||||
daemon.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import xml.etree.ElementTree as ET
|
||||
from typing import List, Union
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from .constants import ArgDirection, PropertyAccess
|
||||
from .errors import InvalidIntrospectionError
|
||||
@ -31,8 +31,8 @@ class Arg:
|
||||
def __init__(
|
||||
self,
|
||||
signature: Union[SignatureType, str],
|
||||
direction: List[ArgDirection] = None,
|
||||
name: str = None,
|
||||
direction: Optional[List[ArgDirection]] = None,
|
||||
name: Optional[str] = None,
|
||||
):
|
||||
if name is not None:
|
||||
assert_member_name_valid(name)
|
||||
@ -105,7 +105,7 @@ class Signal:
|
||||
- :class:`InvalidMemberNameError <dbus_fast.InvalidMemberNameError>` - If the name of the signal is not a valid member name.
|
||||
"""
|
||||
|
||||
def __init__(self, name: str, args: List[Arg] = None):
|
||||
def __init__(self, name: Optional[str], args: Optional[List[Arg]] = None):
|
||||
if name is not None:
|
||||
assert_member_name_valid(name)
|
||||
|
||||
@ -312,9 +312,9 @@ class Interface:
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
methods: List[Method] = None,
|
||||
signals: List[Signal] = None,
|
||||
properties: List[Property] = None,
|
||||
methods: Optional[List[Method]] = None,
|
||||
signals: Optional[List[Signal]] = None,
|
||||
properties: Optional[List[Property]] = None,
|
||||
):
|
||||
assert_interface_name_valid(name)
|
||||
|
||||
@ -395,7 +395,10 @@ class Node:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, name: str = None, interfaces: List[Interface] = None, is_root: bool = True
|
||||
self,
|
||||
name: Optional[str] = None,
|
||||
interfaces: Optional[List[Interface]] = None,
|
||||
is_root: bool = True,
|
||||
):
|
||||
if not is_root and not name:
|
||||
raise InvalidIntrospectionError('child nodes must have a "name" attribute')
|
||||
@ -487,7 +490,7 @@ class Node:
|
||||
return header + ET.tostring(xml, encoding="unicode").rstrip()
|
||||
|
||||
@staticmethod
|
||||
def default(name: str = None) -> "Node":
|
||||
def default(name: Optional[str] = None) -> "Node":
|
||||
"""Create a :class:`Node` with the default interfaces supported by this library.
|
||||
|
||||
The default interfaces include:
|
||||
|
||||
@ -71,7 +71,7 @@ class _Method:
|
||||
self.out_signature_tree = get_signature_tree(out_signature)
|
||||
|
||||
|
||||
def method(name: str = None, disabled: bool = False):
|
||||
def method(name: Optional[str] = None, disabled: bool = False):
|
||||
"""A decorator to mark a class method of a :class:`ServiceInterface` to be a DBus service method.
|
||||
|
||||
The parameters and return value must each be annotated with a signature
|
||||
@ -149,7 +149,7 @@ class _Signal:
|
||||
self.introspection = intr.Signal(self.name, args)
|
||||
|
||||
|
||||
def signal(name: str = None, disabled: bool = False):
|
||||
def signal(name: Optional[str] = None, disabled: bool = False):
|
||||
"""A decorator to mark a class method of a :class:`ServiceInterface` to be a DBus signal.
|
||||
|
||||
The signal is broadcast on the bus when the decorated class method is
|
||||
@ -271,7 +271,7 @@ class _Property(property):
|
||||
|
||||
def dbus_property(
|
||||
access: PropertyAccess = PropertyAccess.READWRITE,
|
||||
name: str = None,
|
||||
name: Optional[str] = None,
|
||||
disabled: bool = False,
|
||||
):
|
||||
"""A decorator to mark a class method of a :class:`ServiceInterface` to be a DBus property.
|
||||
@ -350,9 +350,9 @@ class ServiceInterface:
|
||||
self.__properties: List[_Property] = []
|
||||
self.__signals: List[_Signal] = []
|
||||
self.__buses = set()
|
||||
self.__handlers: dict[
|
||||
self.__handlers: Dict[
|
||||
BaseMessageBus,
|
||||
dict[_Method, Callable[[Message, Callable[[Message], None]], None]],
|
||||
Dict[_Method, Callable[[Message, Callable[[Message], None]], None]],
|
||||
] = {}
|
||||
|
||||
for name, member in inspect.getmembers(type(self)):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user