chore(pre-commit.ci): pre-commit autoupdate (#427)
* chore(pre-commit.ci): pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.0 → v0.11.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.0...v0.11.0) * chore(pre-commit.ci): auto fixes * chore: fix violations --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
28615ee7eb
commit
bfc8151005
@ -38,7 +38,7 @@ repos:
|
|||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: [--py39-plus]
|
args: [--py39-plus]
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.1.0
|
rev: v0.11.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: [--fix, --exit-non-zero-on-fix]
|
args: [--fix, --exit-non-zero-on-fix]
|
||||||
|
|||||||
@ -7,9 +7,10 @@ sys.path.append(os.path.abspath(os.path.dirname(__file__) + "/.."))
|
|||||||
import json
|
import json
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
|
from gi.repository import GLib
|
||||||
|
|
||||||
from dbus_fast import Message
|
from dbus_fast import Message
|
||||||
from dbus_fast.glib import MessageBus
|
from dbus_fast.glib import MessageBus
|
||||||
from gi.repository import GLib
|
|
||||||
|
|
||||||
main = GLib.MainLoop()
|
main = GLib.MainLoop()
|
||||||
bus = MessageBus().connect_sync()
|
bus = MessageBus().connect_sync()
|
||||||
|
|||||||
@ -108,15 +108,9 @@ class ErrorType(str, Enum):
|
|||||||
:seealso: http://man7.org/linux/man-pages/man3/sd-bus-errors.3.html
|
:seealso: http://man7.org/linux/man-pages/man3/sd-bus-errors.3.html
|
||||||
"""
|
"""
|
||||||
|
|
||||||
SERVICE_ERROR = (
|
SERVICE_ERROR = "com.dubstepdish.dbus.next.ServiceError" #: A custom error to indicate an exported service threw an exception.
|
||||||
"com.dubstepdish.dbus.next.ServiceError"
|
INTERNAL_ERROR = "com.dubstepdish.dbus.next.InternalError" #: A custom error to indicate something went wrong with the library.
|
||||||
) #: A custom error to indicate an exported service threw an exception.
|
CLIENT_ERROR = "com.dubstepdish.dbus.next.ClientError" #: A custom error to indicate something went wrong with the client.
|
||||||
INTERNAL_ERROR = (
|
|
||||||
"com.dubstepdish.dbus.next.InternalError"
|
|
||||||
) #: A custom error to indicate something went wrong with the library.
|
|
||||||
CLIENT_ERROR = (
|
|
||||||
"com.dubstepdish.dbus.next.ClientError"
|
|
||||||
) #: A custom error to indicate something went wrong with the client.
|
|
||||||
|
|
||||||
FAILED = "org.freedesktop.DBus.Error.Failed"
|
FAILED = "org.freedesktop.DBus.Error.Failed"
|
||||||
NO_MEMORY = "org.freedesktop.DBus.Error.NoMemory"
|
NO_MEMORY = "org.freedesktop.DBus.Error.NoMemory"
|
||||||
|
|||||||
@ -564,8 +564,8 @@ class Node:
|
|||||||
elem.text = i + " "
|
elem.text = i + " "
|
||||||
if not elem.tail or not elem.tail.strip():
|
if not elem.tail or not elem.tail.strip():
|
||||||
elem.tail = i
|
elem.tail = i
|
||||||
for elem in elem:
|
for elem_ in elem:
|
||||||
indent(elem, level + 1)
|
indent(elem_, level + 1)
|
||||||
if not elem.tail or not elem.tail.strip():
|
if not elem.tail or not elem.tail.strip():
|
||||||
elem.tail = i
|
elem.tail = i
|
||||||
elif level and (not elem.tail or not elem.tail.strip()):
|
elif level and (not elem.tail or not elem.tail.strip()):
|
||||||
|
|||||||
@ -33,8 +33,7 @@ HandlerType = Callable[[Message, SendReply], None]
|
|||||||
|
|
||||||
|
|
||||||
class _MethodCallbackProtocol(Protocol):
|
class _MethodCallbackProtocol(Protocol):
|
||||||
def __call__(self, interface: ServiceInterface, *args: Any) -> Any:
|
def __call__(self, interface: ServiceInterface, *args: Any) -> Any: ...
|
||||||
...
|
|
||||||
|
|
||||||
|
|
||||||
class _Method:
|
class _Method:
|
||||||
@ -381,7 +380,7 @@ class ServiceInterface:
|
|||||||
self.__handlers_by_name_signature: dict[
|
self.__handlers_by_name_signature: dict[
|
||||||
BaseMessageBus, dict[str, tuple[_Method, HandlerType]]
|
BaseMessageBus, dict[str, tuple[_Method, HandlerType]]
|
||||||
] = {}
|
] = {}
|
||||||
for name, member in inspect.getmembers(type(self)):
|
for _, member in inspect.getmembers(type(self)):
|
||||||
member_dict = getattr(member, "__dict__", {})
|
member_dict = getattr(member, "__dict__", {})
|
||||||
if type(member) is _Property:
|
if type(member) is _Property:
|
||||||
# XXX The getter and the setter may show up as different
|
# XXX The getter and the setter may show up as different
|
||||||
@ -668,8 +667,8 @@ class ServiceInterface:
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
result[prop.name] = Variant(prop.signature, value)
|
result[prop.name] = Variant(prop.signature, value)
|
||||||
except SignatureBodyMismatchError as e:
|
except SignatureBodyMismatchError as exc:
|
||||||
result_error = e
|
result_error = exc
|
||||||
del result[prop.name]
|
del result[prop.name]
|
||||||
|
|
||||||
if any(v is None for v in result.values()):
|
if any(v is None for v in result.values()):
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
from dbus_fast import Message
|
|
||||||
from pytest_codspeed import BenchmarkFixture
|
from pytest_codspeed import BenchmarkFixture
|
||||||
|
|
||||||
|
from dbus_fast import Message
|
||||||
|
|
||||||
message = Message(
|
message = Message(
|
||||||
destination="org.bluez",
|
destination="org.bluez",
|
||||||
path="/",
|
path="/",
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import io
|
import io
|
||||||
|
|
||||||
from dbus_fast._private.unmarshaller import Unmarshaller
|
|
||||||
from pytest_codspeed import BenchmarkFixture
|
from pytest_codspeed import BenchmarkFixture
|
||||||
|
|
||||||
|
from dbus_fast._private.unmarshaller import Unmarshaller
|
||||||
|
|
||||||
|
|
||||||
def test_unmarshall_bluez_rssi_message(benchmark: BenchmarkFixture) -> None:
|
def test_unmarshall_bluez_rssi_message(benchmark: BenchmarkFixture) -> None:
|
||||||
bluez_rssi_message = (
|
bluez_rssi_message = (
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import aio
|
from dbus_fast import aio
|
||||||
from dbus_fast.service import ServiceInterface
|
from dbus_fast.service import ServiceInterface
|
||||||
|
|
||||||
|
|||||||
@ -3,13 +3,13 @@ import sys
|
|||||||
from logging.handlers import QueueHandler
|
from logging.handlers import QueueHandler
|
||||||
from queue import SimpleQueue
|
from queue import SimpleQueue
|
||||||
|
|
||||||
import dbus_fast.introspection as intr
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import dbus_fast.introspection as intr
|
||||||
from dbus_fast import DBusError, aio, glib
|
from dbus_fast import DBusError, aio, glib
|
||||||
from dbus_fast.message import MessageFlag
|
from dbus_fast.message import MessageFlag
|
||||||
from dbus_fast.service import ServiceInterface, method
|
from dbus_fast.service import ServiceInterface, method
|
||||||
from dbus_fast.signature import Variant
|
from dbus_fast.signature import Variant
|
||||||
|
|
||||||
from tests.util import check_gi_repository, skip_reason_no_gi
|
from tests.util import check_gi_repository, skip_reason_no_gi
|
||||||
|
|
||||||
has_gi = check_gi_repository()
|
has_gi = check_gi_repository()
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import DBusError, Message, aio, glib
|
from dbus_fast import DBusError, Message, aio, glib
|
||||||
from dbus_fast.service import PropertyAccess, ServiceInterface, dbus_property
|
from dbus_fast.service import PropertyAccess, ServiceInterface, dbus_property
|
||||||
from dbus_fast.signature import Variant
|
from dbus_fast.signature import Variant
|
||||||
|
|
||||||
from tests.util import check_gi_repository, skip_reason_no_gi
|
from tests.util import check_gi_repository, skip_reason_no_gi
|
||||||
|
|
||||||
has_gi = check_gi_repository()
|
has_gi = check_gi_repository()
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import Message
|
from dbus_fast import Message
|
||||||
from dbus_fast.aio import MessageBus
|
from dbus_fast.aio import MessageBus
|
||||||
from dbus_fast.constants import RequestNameReply
|
from dbus_fast.constants import RequestNameReply
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import Message, MessageType
|
from dbus_fast import Message, MessageType
|
||||||
from dbus_fast import introspection as intr
|
from dbus_fast import introspection as intr
|
||||||
from dbus_fast.aio import MessageBus
|
from dbus_fast.aio import MessageBus
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import (
|
from dbus_fast import (
|
||||||
DBusError,
|
DBusError,
|
||||||
ErrorType,
|
ErrorType,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import (
|
from dbus_fast import (
|
||||||
DBusError,
|
DBusError,
|
||||||
ErrorType,
|
ErrorType,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import Message, MessageType
|
from dbus_fast import Message, MessageType
|
||||||
from dbus_fast.aio import MessageBus
|
from dbus_fast.aio import MessageBus
|
||||||
from dbus_fast.constants import PropertyAccess
|
from dbus_fast.constants import PropertyAccess
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import Message, MessageType
|
from dbus_fast import Message, MessageType
|
||||||
from dbus_fast import introspection as intr
|
from dbus_fast import introspection as intr
|
||||||
from dbus_fast.aio import MessageBus
|
from dbus_fast.aio import MessageBus
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import os
|
|||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast._private.address import (
|
from dbus_fast._private.address import (
|
||||||
get_bus_address,
|
get_bus_address,
|
||||||
get_session_bus_address,
|
get_session_bus_address,
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import Message, MessageFlag, MessageType
|
from dbus_fast import Message, MessageFlag, MessageType
|
||||||
from dbus_fast.aio import MessageBus
|
from dbus_fast.aio import MessageBus
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast.aio import MessageBus
|
from dbus_fast.aio import MessageBus
|
||||||
from dbus_fast.service import ServiceInterface, method
|
from dbus_fast.service import ServiceInterface, method
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
"""This tests setting a hardcoded UID in AuthExternal"""
|
"""This tests setting a hardcoded UID in AuthExternal"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast.auth import (
|
from dbus_fast.auth import (
|
||||||
UID_NOT_SPECIFIED,
|
UID_NOT_SPECIFIED,
|
||||||
AuthAnnonymous,
|
AuthAnnonymous,
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import Message, MessageType, aio, glib
|
from dbus_fast import Message, MessageType, aio, glib
|
||||||
from dbus_fast.service import ServiceInterface, method
|
from dbus_fast.service import ServiceInterface, method
|
||||||
|
|
||||||
from tests.util import check_gi_repository, skip_reason_no_gi
|
from tests.util import check_gi_repository, skip_reason_no_gi
|
||||||
|
|
||||||
has_gi = check_gi_repository()
|
has_gi = check_gi_repository()
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import asyncio
|
|||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import Message
|
from dbus_fast import Message
|
||||||
from dbus_fast.aio import MessageBus
|
from dbus_fast.aio import MessageBus
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import Message, MessageType
|
from dbus_fast import Message, MessageType
|
||||||
from dbus_fast.aio import MessageBus
|
from dbus_fast.aio import MessageBus
|
||||||
from dbus_fast.service import ServiceInterface, dbus_property, method, signal
|
from dbus_fast.service import ServiceInterface, dbus_property, method, signal
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import Message, MessageFlag, MessageType
|
from dbus_fast import Message, MessageFlag, MessageType
|
||||||
from dbus_fast.glib import MessageBus
|
from dbus_fast.glib import MessageBus
|
||||||
|
|
||||||
from tests.util import check_gi_repository, skip_reason_no_gi
|
from tests.util import check_gi_repository, skip_reason_no_gi
|
||||||
|
|
||||||
has_gi = check_gi_repository()
|
has_gi = check_gi_repository()
|
||||||
|
|||||||
@ -5,6 +5,7 @@ from enum import Enum
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import Message, MessageFlag, MessageType, SignatureTree, Variant
|
from dbus_fast import Message, MessageFlag, MessageType, SignatureTree, Variant
|
||||||
from dbus_fast._private._cython_compat import FakeCython
|
from dbus_fast._private._cython_compat import FakeCython
|
||||||
from dbus_fast._private.constants import BIG_ENDIAN, LITTLE_ENDIAN
|
from dbus_fast._private.constants import BIG_ENDIAN, LITTLE_ENDIAN
|
||||||
@ -233,9 +234,9 @@ def test_unmarshalling_with_table(unmarshall_table):
|
|||||||
"flags",
|
"flags",
|
||||||
"serial",
|
"serial",
|
||||||
]:
|
]:
|
||||||
assert getattr(unmarshaller.message, attr) == getattr(
|
assert getattr(unmarshaller.message, attr) == getattr(message, attr), (
|
||||||
message, attr
|
f"attr doesnt match: {attr}"
|
||||||
), f"attr doesnt match: {attr}"
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_unmarshall_can_resume():
|
def test_unmarshall_can_resume():
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import (
|
from dbus_fast import (
|
||||||
Message,
|
Message,
|
||||||
MessageType,
|
MessageType,
|
||||||
@ -10,7 +11,6 @@ from dbus_fast import (
|
|||||||
aio,
|
aio,
|
||||||
glib,
|
glib,
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.util import check_gi_repository, skip_reason_no_gi
|
from tests.util import check_gi_repository, skip_reason_no_gi
|
||||||
|
|
||||||
has_gi = check_gi_repository()
|
has_gi = check_gi_repository()
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import os
|
|||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast.constants import ErrorType, MessageType
|
from dbus_fast.constants import ErrorType, MessageType
|
||||||
from dbus_fast.errors import DBusError
|
from dbus_fast.errors import DBusError
|
||||||
from dbus_fast.message import Message
|
from dbus_fast.message import Message
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import SignatureBodyMismatchError, SignatureTree, Variant
|
from dbus_fast import SignatureBodyMismatchError, SignatureTree, Variant
|
||||||
from dbus_fast._private.util import signature_contains_type
|
from dbus_fast._private.util import signature_contains_type
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import os
|
|||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast import Message
|
from dbus_fast import Message
|
||||||
from dbus_fast._private.address import parse_address
|
from dbus_fast._private.address import parse_address
|
||||||
from dbus_fast.aio import MessageBus
|
from dbus_fast.aio import MessageBus
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
"""Test unpack variants."""
|
"""Test unpack variants."""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbus_fast.signature import Variant
|
from dbus_fast.signature import Variant
|
||||||
from dbus_fast.unpack import unpack_variants
|
from dbus_fast.unpack import unpack_variants
|
||||||
|
|
||||||
|
|||||||
@ -66,13 +66,13 @@ def test_interface_name_validator():
|
|||||||
]
|
]
|
||||||
|
|
||||||
for name in valid_names:
|
for name in valid_names:
|
||||||
assert is_interface_name_valid(
|
assert is_interface_name_valid(name), (
|
||||||
name
|
f'interface name should be valid: "{name}"'
|
||||||
), f'interface name should be valid: "{name}"'
|
)
|
||||||
for name in invalid_names:
|
for name in invalid_names:
|
||||||
assert not is_interface_name_valid(
|
assert not is_interface_name_valid(name), (
|
||||||
name
|
f'interface name should be invalid: "{name}"'
|
||||||
), f'interface name should be invalid: "{name}"'
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_member_name_validator():
|
def test_member_name_validator():
|
||||||
@ -82,6 +82,6 @@ def test_member_name_validator():
|
|||||||
for member in valid_members:
|
for member in valid_members:
|
||||||
assert is_member_name_valid(member), f'member name should be valid: "{member}"'
|
assert is_member_name_valid(member), f'member name should be valid: "{member}"'
|
||||||
for member in invalid_members:
|
for member in invalid_members:
|
||||||
assert not is_member_name_valid(
|
assert not is_member_name_valid(member), (
|
||||||
member
|
f'member name should be invalid: "{member}"'
|
||||||
), f'member name should be invalid: "{member}"'
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user