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:
pre-commit-ci[bot] 2025-03-17 11:01:24 -10:00 committed by GitHub
parent 28615ee7eb
commit bfc8151005
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 52 additions and 38 deletions

View File

@ -38,7 +38,7 @@ repos:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.0
rev: v0.11.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

View File

@ -7,9 +7,10 @@ sys.path.append(os.path.abspath(os.path.dirname(__file__) + "/.."))
import json
import signal
from gi.repository import GLib
from dbus_fast import Message
from dbus_fast.glib import MessageBus
from gi.repository import GLib
main = GLib.MainLoop()
bus = MessageBus().connect_sync()

View File

@ -108,15 +108,9 @@ class ErrorType(str, Enum):
:seealso: http://man7.org/linux/man-pages/man3/sd-bus-errors.3.html
"""
SERVICE_ERROR = (
"com.dubstepdish.dbus.next.ServiceError"
) #: A custom error to indicate an exported service threw an exception.
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.
SERVICE_ERROR = "com.dubstepdish.dbus.next.ServiceError" #: A custom error to indicate an exported service threw an exception.
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"
NO_MEMORY = "org.freedesktop.DBus.Error.NoMemory"

View File

@ -564,8 +564,8 @@ class Node:
elem.text = i + " "
if not elem.tail or not elem.tail.strip():
elem.tail = i
for elem in elem:
indent(elem, level + 1)
for elem_ in elem:
indent(elem_, level + 1)
if not elem.tail or not elem.tail.strip():
elem.tail = i
elif level and (not elem.tail or not elem.tail.strip()):

View File

@ -33,8 +33,7 @@ HandlerType = Callable[[Message, SendReply], None]
class _MethodCallbackProtocol(Protocol):
def __call__(self, interface: ServiceInterface, *args: Any) -> Any:
...
def __call__(self, interface: ServiceInterface, *args: Any) -> Any: ...
class _Method:
@ -381,7 +380,7 @@ class ServiceInterface:
self.__handlers_by_name_signature: dict[
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__", {})
if type(member) is _Property:
# XXX The getter and the setter may show up as different
@ -668,8 +667,8 @@ class ServiceInterface:
else:
try:
result[prop.name] = Variant(prop.signature, value)
except SignatureBodyMismatchError as e:
result_error = e
except SignatureBodyMismatchError as exc:
result_error = exc
del result[prop.name]
if any(v is None for v in result.values()):

View File

@ -1,6 +1,7 @@
from dbus_fast import Message
from pytest_codspeed import BenchmarkFixture
from dbus_fast import Message
message = Message(
destination="org.bluez",
path="/",

View File

@ -1,8 +1,9 @@
import io
from dbus_fast._private.unmarshaller import Unmarshaller
from pytest_codspeed import BenchmarkFixture
from dbus_fast._private.unmarshaller import Unmarshaller
def test_unmarshall_bluez_rssi_message(benchmark: BenchmarkFixture) -> None:
bluez_rssi_message = (

View File

@ -1,4 +1,5 @@
import pytest
from dbus_fast import aio
from dbus_fast.service import ServiceInterface

View File

@ -3,13 +3,13 @@ import sys
from logging.handlers import QueueHandler
from queue import SimpleQueue
import dbus_fast.introspection as intr
import pytest
import dbus_fast.introspection as intr
from dbus_fast import DBusError, aio, glib
from dbus_fast.message import MessageFlag
from dbus_fast.service import ServiceInterface, method
from dbus_fast.signature import Variant
from tests.util import check_gi_repository, skip_reason_no_gi
has_gi = check_gi_repository()

View File

@ -1,10 +1,10 @@
import sys
import pytest
from dbus_fast import DBusError, Message, aio, glib
from dbus_fast.service import PropertyAccess, ServiceInterface, dbus_property
from dbus_fast.signature import Variant
from tests.util import check_gi_repository, skip_reason_no_gi
has_gi = check_gi_repository()

View File

@ -1,6 +1,7 @@
import asyncio
import pytest
from dbus_fast import Message
from dbus_fast.aio import MessageBus
from dbus_fast.constants import RequestNameReply

View File

@ -1,4 +1,5 @@
import pytest
from dbus_fast import Message, MessageType
from dbus_fast import introspection as intr
from dbus_fast.aio import MessageBus

View File

@ -1,4 +1,5 @@
import pytest
from dbus_fast import (
DBusError,
ErrorType,

View File

@ -1,6 +1,7 @@
import asyncio
import pytest
from dbus_fast import (
DBusError,
ErrorType,

View File

@ -1,6 +1,7 @@
import asyncio
import pytest
from dbus_fast import Message, MessageType
from dbus_fast.aio import MessageBus
from dbus_fast.constants import PropertyAccess

View File

@ -1,4 +1,5 @@
import pytest
from dbus_fast import Message, MessageType
from dbus_fast import introspection as intr
from dbus_fast.aio import MessageBus

View File

@ -2,6 +2,7 @@ import os
from unittest.mock import patch
import pytest
from dbus_fast._private.address import (
get_bus_address,
get_session_bus_address,

View File

@ -1,4 +1,5 @@
import pytest
from dbus_fast import Message, MessageFlag, MessageType
from dbus_fast.aio import MessageBus

View File

@ -1,4 +1,5 @@
import pytest
from dbus_fast.aio import MessageBus
from dbus_fast.service import ServiceInterface, method

View File

@ -1,6 +1,7 @@
"""This tests setting a hardcoded UID in AuthExternal"""
import pytest
from dbus_fast.auth import (
UID_NOT_SPECIFIED,
AuthAnnonymous,

View File

@ -1,9 +1,9 @@
import sys
import pytest
from dbus_fast import Message, MessageType, aio, glib
from dbus_fast.service import ServiceInterface, method
from tests.util import check_gi_repository, skip_reason_no_gi
has_gi = check_gi_repository()

View File

@ -2,6 +2,7 @@ import asyncio
from unittest.mock import patch
import pytest
from dbus_fast import Message
from dbus_fast.aio import MessageBus

View File

@ -3,6 +3,7 @@
import os
import pytest
from dbus_fast import Message, MessageType
from dbus_fast.aio import MessageBus
from dbus_fast.service import ServiceInterface, dbus_property, method, signal

View File

@ -1,9 +1,9 @@
import sys
import pytest
from dbus_fast import Message, MessageFlag, MessageType
from dbus_fast.glib import MessageBus
from tests.util import check_gi_repository, skip_reason_no_gi
has_gi = check_gi_repository()

View File

@ -5,6 +5,7 @@ from enum import Enum
from typing import Any
import pytest
from dbus_fast import Message, MessageFlag, MessageType, SignatureTree, Variant
from dbus_fast._private._cython_compat import FakeCython
from dbus_fast._private.constants import BIG_ENDIAN, LITTLE_ENDIAN
@ -233,9 +234,9 @@ def test_unmarshalling_with_table(unmarshall_table):
"flags",
"serial",
]:
assert getattr(unmarshaller.message, attr) == getattr(
message, attr
), f"attr doesnt match: {attr}"
assert getattr(unmarshaller.message, attr) == getattr(message, attr), (
f"attr doesnt match: {attr}"
)
def test_unmarshall_can_resume():

View File

@ -1,6 +1,7 @@
import sys
import pytest
from dbus_fast import (
Message,
MessageType,
@ -10,7 +11,6 @@ from dbus_fast import (
aio,
glib,
)
from tests.util import check_gi_repository, skip_reason_no_gi
has_gi = check_gi_repository()

View File

@ -2,6 +2,7 @@ import os
from unittest.mock import patch
import pytest
from dbus_fast.constants import ErrorType, MessageType
from dbus_fast.errors import DBusError
from dbus_fast.message import Message

View File

@ -1,4 +1,5 @@
import pytest
from dbus_fast import SignatureBodyMismatchError, SignatureTree, Variant
from dbus_fast._private.util import signature_contains_type

View File

@ -3,6 +3,7 @@ import os
from contextlib import suppress
import pytest
from dbus_fast import Message
from dbus_fast._private.address import parse_address
from dbus_fast.aio import MessageBus

View File

@ -1,6 +1,7 @@
"""Test unpack variants."""
import pytest
from dbus_fast.signature import Variant
from dbus_fast.unpack import unpack_variants

View File

@ -66,13 +66,13 @@ def test_interface_name_validator():
]
for name in valid_names:
assert is_interface_name_valid(
name
), f'interface name should be valid: "{name}"'
assert is_interface_name_valid(name), (
f'interface name should be valid: "{name}"'
)
for name in invalid_names:
assert not is_interface_name_valid(
name
), f'interface name should be invalid: "{name}"'
assert not is_interface_name_valid(name), (
f'interface name should be invalid: "{name}"'
)
def test_member_name_validator():
@ -82,6 +82,6 @@ def test_member_name_validator():
for member in valid_members:
assert is_member_name_valid(member), f'member name should be valid: "{member}"'
for member in invalid_members:
assert not is_member_name_valid(
member
), f'member name should be invalid: "{member}"'
assert not is_member_name_valid(member), (
f'member name should be invalid: "{member}"'
)