mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-01 10:31:54 +08:00
new typing style
This commit is contained in:
@@ -24,11 +24,8 @@ import os
|
||||
import contextlib
|
||||
import time
|
||||
|
||||
from typing import List
|
||||
from typing import Dict
|
||||
from typing import Generator
|
||||
from typing import Callable
|
||||
from typing import Optional
|
||||
from typing import Any
|
||||
|
||||
import spidev
|
||||
@@ -75,7 +72,7 @@ class _SpiPhyConnection(BasePhyConnection):
|
||||
|
||||
self.__xfer(request)
|
||||
|
||||
response: List[int] = []
|
||||
response: list[int] = []
|
||||
deadline_ts = time.monotonic() + self.__read_timeout
|
||||
found = False
|
||||
while time.monotonic() < deadline_ts:
|
||||
@@ -143,7 +140,7 @@ class _SpiPhy(BasePhy): # pylint: disable=too-many-instance-attributes
|
||||
)
|
||||
|
||||
@contextlib.contextmanager
|
||||
def __sw_cs_connected(self) -> Generator[Optional[gpiod.Line], None, None]:
|
||||
def __sw_cs_connected(self) -> Generator[(gpiod.Line | None), None, None]:
|
||||
if self.__sw_cs_pin > 0:
|
||||
with contextlib.closing(gpiod.Chip(self.__gpio_device_path)) as chip:
|
||||
line = chip.get_line(self.__sw_cs_pin)
|
||||
@@ -156,19 +153,19 @@ class _SpiPhy(BasePhy): # pylint: disable=too-many-instance-attributes
|
||||
# =====
|
||||
class Plugin(BaseMcuHid):
|
||||
def __init__(self, **kwargs: Any) -> None:
|
||||
phy_kwargs: Dict = {key: kwargs.pop(key) for key in self.__get_phy_options()}
|
||||
phy_kwargs: dict = {key: kwargs.pop(key) for key in self.__get_phy_options()}
|
||||
phy_kwargs["gpio_device_path"] = kwargs["gpio_device_path"]
|
||||
super().__init__(phy=_SpiPhy(**phy_kwargs), **kwargs)
|
||||
|
||||
@classmethod
|
||||
def get_plugin_options(cls) -> Dict:
|
||||
def get_plugin_options(cls) -> dict:
|
||||
return {
|
||||
**cls.__get_phy_options(),
|
||||
**BaseMcuHid.get_plugin_options(),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def __get_phy_options(cls) -> Dict:
|
||||
def __get_phy_options(cls) -> dict:
|
||||
return {
|
||||
"bus": Option(-1, type=valid_int_f0),
|
||||
"chip": Option(-1, type=valid_int_f0),
|
||||
|
||||
Reference in New Issue
Block a user