Skip to content

Commit a4baf4d

Browse files
committed
Add pydbus stubs
1 parent a46eea7 commit a4baf4d

19 files changed

+407
-0
lines changed

stubs/pydbus/METADATA.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version = "0.6.*"
2+
requires = ["pygobject-stubs"]
3+
upstream_repository = "https://github.com/LEW21/pydbus"

stubs/pydbus/pydbus/__init__.pyi

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from gi.repository.GLib import Variant
2+
3+
from .bus import SessionBus, SystemBus, connect
4+
5+
__all__ = ("SessionBus", "SystemBus", "Variant", "connect")

stubs/pydbus/pydbus/_inspect3.pyi

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from collections.abc import Callable, Iterable
2+
from typing import Any
3+
4+
class _empty: ...
5+
6+
class Signature:
7+
empty: _empty
8+
parameters: Any
9+
return_annotation: Any
10+
11+
def __init__(self, parameters: Iterable[Parameter] | None = None, return_annotation: Any = ...) -> None: ...
12+
13+
class Parameter:
14+
empty: _empty
15+
POSITIONAL_ONLY: int
16+
POSITIONAL_OR_KEYWORD: int
17+
KEYWORD_ONLY: int
18+
name: str
19+
kind: int
20+
annotation: Any
21+
22+
def __init__(self, name: str, kind: int, default: Any = ..., annotation: Any = ...) -> None: ...
23+
24+
def signature(f: Callable[..., Any]) -> Signature: ...

stubs/pydbus/pydbus/auto_names.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def auto_bus_name(bus_name: str) -> str: ...
2+
def auto_object_path(bus_name: str, object_path: str | None = None) -> str: ...

stubs/pydbus/pydbus/bus.pyi

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import types
2+
from typing import Any, Literal, TypedDict, overload
3+
from typing_extensions import Self
4+
5+
from gi.repository import Gio
6+
7+
from .bus_names import OwnMixin, WatchMixin
8+
from .proxy import ProxyMixin
9+
from .publication import PublicationMixin
10+
from .registration import RegistrationMixin
11+
from .request_name import RequestNameMixin
12+
from .subscription import SubscriptionMixin
13+
14+
# Gio.DBusConnection.pydbus: Bus
15+
16+
def bus_get(type: Gio.BusType) -> Bus: ...
17+
def connect(address: str) -> Bus: ...
18+
19+
class DBusOrgFreedesktopDBus:
20+
# Incomplete DBUS.org.freedesktop.DBus
21+
Features: list[str]
22+
23+
def GetId(self) -> str: ...
24+
25+
class DBusOrgFreedesktopPolicyKit1Authority:
26+
# Incomplete DBUS.org.freedesktop.PolicyKit1.Authority
27+
BackendName: str
28+
BackendVersion: str
29+
30+
OrgBluezDict = TypedDict(
31+
"OrgBluezDict",
32+
{
33+
"org.bluez.AgentManager1": dict[Any, Any],
34+
"org.bluez.ProfileManager1": dict[Any, Any],
35+
"org.freedesktop.DBus.Introspectable": dict[Any, Any],
36+
},
37+
)
38+
OrgBluesHci0Dict = TypedDict("OrgBluesHci0Dict", {"org.bluez.Adapter1": dict[str, Any]})
39+
40+
DBusOrgFreedesktopDBusObjectManagerManagedObjectsDict = TypedDict(
41+
"DBusOrgFreedesktopDBusObjectManagerManagedObjectsDict", {"/org/bluez": OrgBluezDict, "/org/bluez/hci0": OrgBluesHci0Dict}
42+
)
43+
44+
class DBusOrgFreedesktopDBusObjectManager:
45+
x: int
46+
y: int
47+
48+
@staticmethod
49+
def GetManagedObjects() -> dict[str, Any]: ...
50+
51+
class Bluez:
52+
def __getitem__(self, key: Literal["org.freedesktop.DBus.ObjectManager"]) -> DBusOrgFreedesktopDBusObjectManager: ...
53+
54+
class Notifications:
55+
Inhibited: bool
56+
57+
def UnInhibit(self, key: int) -> int | None: ...
58+
def Inhibit(self, name: str, reason: str, unk1: Any) -> int | None: ...
59+
60+
class Bus(ProxyMixin, RequestNameMixin, OwnMixin, WatchMixin, SubscriptionMixin, RegistrationMixin, PublicationMixin):
61+
Type: type[Gio.BusType] = ...
62+
autoclose: bool
63+
con: Gio.DBusConnection
64+
65+
def __init__(self, gio_con: Gio.DBusConnection) -> None: ...
66+
def __enter__(self) -> Self: ...
67+
def __exit__(
68+
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: types.TracebackType | None
69+
) -> None: ...
70+
@property
71+
def dbus(self) -> DBusOrgFreedesktopDBus: ...
72+
@property
73+
def polkit_authority(self) -> DBusOrgFreedesktopPolicyKit1Authority: ...
74+
@overload # type: ignore[override]
75+
def get(
76+
self, domain: Literal["org.freedesktop.Notifications"], path: Literal["/org/freedesktop/Notifications"]
77+
) -> Notifications: ...
78+
@overload
79+
def get(self, domain: Literal["org.bluez"], path: Literal["/"]) -> Bluez: ...
80+
@overload
81+
def get(self, domain: str, path: str) -> Any: ...
82+
83+
def SystemBus() -> Bus: ...
84+
def SessionBus() -> Bus: ...

stubs/pydbus/pydbus/bus_names.pyi

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from collections.abc import Callable
2+
from typing import Any
3+
4+
from gi.repository import Gio
5+
6+
from .exitable import Exitable
7+
8+
class NameOwner(Exitable):
9+
Flags: Gio.BusNameOwnerFlags
10+
11+
def __init__(
12+
self,
13+
con: Gio.DBusConnection,
14+
name: str,
15+
flags: Gio.BusNameOwnerFlags,
16+
name_aquired_handler: Callable[[str], Any],
17+
name_lost_handler: Callable[[str], Any],
18+
) -> None: ...
19+
def unown(self, *args: Any, **kwargs: Any) -> None: ...
20+
21+
class NameWatcher(Exitable):
22+
Flags: Gio.BusNameWatcherFlags
23+
24+
def __init__(
25+
self,
26+
con: Gio.DBusConnection,
27+
name: str,
28+
flags: Gio.BusNameWatcherFlags,
29+
name_appeared_handler: Callable[[str], Any],
30+
name_vanished_handler: Callable[[str], Any],
31+
) -> None: ...
32+
def unwatch(self, *args: Any, **kwargs: Any) -> None: ...
33+
34+
class OwnMixin:
35+
NameOwnerFlags: Gio.BusNameOwnerFlags
36+
37+
def own_name(
38+
self,
39+
name: str,
40+
flags: Gio.BusNameOwnerFlags = ...,
41+
name_aquired: Callable[[str], Any] | None = ...,
42+
name_lost: Callable[[str], Any] | None = ...,
43+
) -> NameOwner: ...
44+
def unwatch(self, *args: Any, **kwargs: Any) -> None: ...
45+
46+
class WatchMixin:
47+
NameWatcherFlags: Gio.BusNameWatcherFlags
48+
49+
def watch_name(
50+
self,
51+
name: str,
52+
flags: Gio.BusNameWatcherFlags = ...,
53+
name_appeared: Callable[[str], Any] | None = ...,
54+
name_vanished: Callable[[str], Any] | None = ...,
55+
) -> NameWatcher: ...

stubs/pydbus/pydbus/exitable.pyi

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import types
2+
from typing import Any
3+
from typing_extensions import Self
4+
5+
class Exitable:
6+
def __enter__(self) -> Self: ...
7+
def __exit__(
8+
self,
9+
exc_type: type[BaseException] | None = None,
10+
exc_value: BaseException | None = None,
11+
traceback: types.TracebackType | None = None,
12+
) -> None: ...
13+
14+
def ExitableWithAliases(*exit_methods: Any) -> Exitable: ...

stubs/pydbus/pydbus/generic.pyi

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import types
2+
from collections.abc import Callable
3+
from typing import Any
4+
from typing_extensions import Self
5+
6+
class subscription:
7+
callback_list: list[Callable[..., Any]]
8+
callback: Callable[..., Any]
9+
10+
def __init__(self, callback_list: list[Callable[..., Any]], callback: Callable[..., Any]) -> None: ...
11+
def unsubscribe(self) -> None: ...
12+
def disconnect(self) -> None: ...
13+
def __enter__(self) -> Self: ...
14+
def __exit__(
15+
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: types.TracebackType | None
16+
) -> None: ...
17+
18+
class bound_signal:
19+
__signal__: signal
20+
21+
def __init__(self, signal: signal, instance: Any) -> None: ...
22+
@property
23+
def callbacks(self) -> list[Callable[..., Any]]: ...
24+
def connect(self, callback: Callable[..., Any]) -> subscription: ...
25+
def emit(self, *args: Any) -> None: ...
26+
def __call__(self, *args: Any) -> None: ...
27+
28+
class signal:
29+
map: dict[Any, Any]
30+
31+
def __init__(self) -> None: ...
32+
def connect(self, object: Any, callback: Callable[..., Any]) -> subscription: ...
33+
def emit(self, object: Any, *args: Any) -> None: ...
34+
def __get__(self, instance: Any, owner: Any) -> Self | bound_signal: ...
35+
def __set__(self, instance: Any, value: Any) -> None: ...
36+
37+
bound_method: Any # type[signal().emit] aka type[Callable[..., Any]]

stubs/pydbus/pydbus/identifier.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def isident(s: str) -> bool: ...
2+
def filter_identifier(name: str) -> str: ...
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from typing import Any, NamedTuple
2+
3+
from gi.repository import Gio
4+
5+
from .bus import Bus
6+
7+
class AuthorizationResult(NamedTuple):
8+
is_authorized: bool
9+
is_challenge: bool
10+
details: Any
11+
12+
class MethodCallContext:
13+
def __init__(self, gdbus_method_invocation: Gio.DBusMethodInvocation) -> None: ...
14+
@property
15+
def bus(self) -> Bus: ...
16+
@property
17+
def sender(self) -> Any: ...
18+
@property
19+
def object_path(self) -> str: ...
20+
@property
21+
def interface_name(self) -> str: ...
22+
@property
23+
def method_name(self) -> str: ...
24+
def check_authorization(self, action_id: str, details: Any, interactive: bool = False) -> AuthorizationResult: ...
25+
def is_authorized(self, action_id: str, details: Any, interactive: bool = False) -> bool: ...

stubs/pydbus/pydbus/proxy.pyi

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import Any
2+
from xml.etree.ElementTree import Element
3+
4+
from .bus import Bus
5+
6+
class CompositeObject: # inside CompositeInterface
7+
def __getitem__(self, iface: str) -> Any: ...
8+
9+
class ProxyMixin:
10+
def get(self, bus_name: str, object_path: str | None = None, **kwargs: Any) -> CompositeObject: ...
11+
12+
class ProxyObject:
13+
def __init__(self, bus: Bus, bus_name: str, path: str, object: Any = None) -> None: ...
14+
15+
def Interface(iface: Element) -> ProxyObject: ...
16+
def CompositeInterface(introspection: Element) -> CompositeObject: ...

stubs/pydbus/pydbus/proxy_method.pyi

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from typing import Any
2+
3+
from ._inspect3 import Signature
4+
5+
put_signature_in_doc: bool
6+
7+
class DBUSSignature(Signature): ...
8+
9+
class ProxyMethod:
10+
__signature__: DBUSSignature
11+
12+
def __init__(self, iface_name: str, method: str) -> None: ...
13+
def __call__(self, instance: Any, *args: Any, **kwargs: Any) -> Any: ...
14+
def __get__(self, instance: Any, owner: Any) -> Any: ...
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from typing import Any
2+
from xml.etree.ElementTree import Element
3+
4+
class ProxyProperty:
5+
def __init__(self, iface_name: str, property: Element) -> None: ...
6+
def __get__(self, instance: Any, owner: Any) -> Any: ...
7+
def __set__(self, instance: Any, value: Any) -> None: ...

stubs/pydbus/pydbus/proxy_signal.pyi

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from collections.abc import Callable
2+
from typing import Any
3+
from typing_extensions import Self
4+
from xml.etree.ElementTree import Element
5+
6+
from .generic import bound_signal
7+
8+
class ProxySignal:
9+
def __init__(self, iface_name: str, signal: Element) -> None: ...
10+
def connect(self, object: Any, callback: Callable[..., Any]) -> Any: ...
11+
def __get__(self, instance: Any, owner: Any) -> bound_signal | Self: ...
12+
def __set__(self, instance: Any, value: Any) -> None: ...
13+
14+
class OnSignal:
15+
signal: ProxySignal
16+
17+
def __init__(self, signal: ProxySignal) -> None: ...
18+
def __get__(self, instance: Any, owner: Any) -> Any: ...
19+
def __set__(self, instance: Any, value: Any) -> None: ...

stubs/pydbus/pydbus/publication.pyi

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from typing import Any
2+
3+
from .bus import Bus
4+
from .exitable import Exitable
5+
6+
class Publication(Exitable):
7+
def __init__(self, bus: Bus, bus_name: str, *objects: Any, **kwargs: Any) -> None: ...
8+
def unpublish(self, *args: Any, **kwargs: Any) -> None: ...
9+
10+
class PublicationMixin:
11+
def publish(self, bus_name: str, *objects: Any) -> Publication: ...

stubs/pydbus/pydbus/registration.pyi

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from collections.abc import Sequence
2+
from typing import Any
3+
from xml.etree.ElementTree import Element
4+
5+
from gi.repository import Gio, GLib
6+
7+
from .bus import Bus
8+
from .exitable import Exitable
9+
from .generic import signal
10+
11+
class ObjectWrapper(Exitable):
12+
object: Any
13+
outargs: dict[str, Any]
14+
readable_properties: dict[str, Any]
15+
writable_properties: dict[str, Any]
16+
17+
def __init__(self, object: Any, interfaces: Element) -> None: ...
18+
19+
SignalEmitted: signal
20+
21+
def call_method(
22+
self,
23+
connection: Gio.DBusConnection,
24+
sender: Any,
25+
object_path: Any,
26+
interface_name: str,
27+
method_name: str,
28+
parameters: Any,
29+
invocation: Gio.DBusMethodInvocation,
30+
) -> None: ...
31+
def Get(self, interface_name: str, property_name: str) -> GLib.Variant: ...
32+
def GetAll(self, interface_name: str) -> dict[str, GLib.Variant]: ...
33+
def Set(self, interface_name: str, property_name: str, value: Any) -> None: ...
34+
def unwrap(self, *args: Any, **kwargs: Any) -> None: ...
35+
36+
class ObjectRegistration(Exitable):
37+
def __init__(self, bus: Bus, path: str, interfaces: Element, wrapper: Any, own_wrapper: bool = False) -> None: ...
38+
def unregister(self, *args: Any, **kwargs: Any) -> None: ...
39+
40+
class RegistrationMixin:
41+
def register_object(self, path: str, object: Any, node_info: Sequence[str]) -> ObjectRegistration: ...

stubs/pydbus/pydbus/request_name.pyi

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from typing import Any
2+
3+
from .bus import Bus
4+
from .exitable import Exitable
5+
6+
class NameOwner(Exitable):
7+
def __init__(self, bus: Bus, name: str, allow_replacement: bool, replace: bool) -> None: ...
8+
def unown(self, *args: Any, **kwargs: Any) -> None: ...
9+
10+
class RequestNameMixin:
11+
def request_name(self, name: str, allow_replacement: bool = True, replace: bool = False) -> NameOwner: ...

0 commit comments

Comments
 (0)