Ruff: Add and fix UP rules

This commit is contained in:
Josh Wu
2026-01-01 03:07:06 +08:00
parent 8e28f4e159
commit 3f643de4c1
102 changed files with 922 additions and 999 deletions

View File

@@ -24,7 +24,8 @@ from __future__ import annotations
import logging
import pathlib
import platform
from typing import TYPE_CHECKING, Iterable, Optional
from collections.abc import Iterable
from typing import TYPE_CHECKING
from bumble.drivers import intel, rtk
from bumble.drivers.common import Driver
@@ -41,7 +42,7 @@ logger = logging.getLogger(__name__)
# -----------------------------------------------------------------------------
# Functions
# -----------------------------------------------------------------------------
async def get_driver_for_host(host: Host) -> Optional[Driver]:
async def get_driver_for_host(host: Host) -> Driver | None:
"""Probe diver classes until one returns a valid instance for a host, or none is
found.
If a "driver" HCI metadata entry is present, only that driver class will be probed.

View File

@@ -29,7 +29,7 @@ import os
import pathlib
import platform
import struct
from typing import TYPE_CHECKING, Any, Optional
from typing import TYPE_CHECKING, Any
from bumble import core, hci, utils
from bumble.drivers import common
@@ -353,8 +353,8 @@ class Driver(common.Driver):
self.reset_complete = asyncio.Event()
# Parse configuration options from the driver name.
self.ddc_addon: Optional[bytes] = None
self.ddc_override: Optional[bytes] = None
self.ddc_addon: bytes | None = None
self.ddc_override: bytes | None = None
driver = host.hci_metadata.get("driver")
if driver is not None and driver.startswith("intel/"):
for key, value in [
@@ -602,7 +602,7 @@ class Driver(common.Driver):
await self.load_ddc_if_any(firmware_base_name)
async def load_ddc_if_any(self, firmware_base_name: Optional[str] = None) -> None:
async def load_ddc_if_any(self, firmware_base_name: str | None = None) -> None:
"""
Check for and load any Device Data Configuration (DDC) blobs.