mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-14 02:00:32 +08:00
lint fixes
This commit is contained in:
parent
791e047a6b
commit
47614a5724
@ -23,6 +23,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import threading
|
import threading
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
import typing
|
||||||
|
|
||||||
import gpiod
|
import gpiod
|
||||||
|
|
||||||
@ -101,10 +102,10 @@ class AioReader: # pylint: disable=too-many-instance-attributes
|
|||||||
if line_req.wait_edge_events(1):
|
if line_req.wait_edge_events(1):
|
||||||
new: dict[int, bool] = {}
|
new: dict[int, bool] = {}
|
||||||
for event in line_req.read_edge_events():
|
for event in line_req.read_edge_events():
|
||||||
(pin, value) = self.__parse_event(event)
|
(pin, state) = self.__parse_event(event)
|
||||||
new[pin] = value
|
new[pin] = state
|
||||||
for (pin, value) in new.items():
|
for (pin, state) in new.items():
|
||||||
self.__values[pin].set(value)
|
self.__values[pin].set(state)
|
||||||
else: # Timeout
|
else: # Timeout
|
||||||
# XXX: Лимит был актуален для 1.6. Надо проверить, поменялось ли это в 2.x.
|
# XXX: Лимит был актуален для 1.6. Надо проверить, поменялось ли это в 2.x.
|
||||||
# Размер буфера ядра - 16 эвентов на линии. При превышении этого числа,
|
# Размер буфера ядра - 16 эвентов на линии. При превышении этого числа,
|
||||||
@ -114,11 +115,12 @@ class AioReader: # pylint: disable=too-many-instance-attributes
|
|||||||
self.__values[pin].set(bool(value.value)) # type: ignore
|
self.__values[pin].set(bool(value.value)) # type: ignore
|
||||||
|
|
||||||
def __parse_event(self, event: gpiod.EdgeEvent) -> tuple[int, bool]:
|
def __parse_event(self, event: gpiod.EdgeEvent) -> tuple[int, bool]:
|
||||||
if event.event_type == event.Type.RISING_EDGE:
|
match event.event_type:
|
||||||
return (event.line_offset, True)
|
case event.Type.RISING_EDGE:
|
||||||
elif event.event_type == event.Type.FALLING_EDGE:
|
return (event.line_offset, True)
|
||||||
return (event.line_offset, False)
|
case event.Type.FALLING_EDGE:
|
||||||
raise RuntimeError(f"Invalid event {event} type: {event.type}")
|
return (event.line_offset, False)
|
||||||
|
typing.assert_never(event.event_type)
|
||||||
|
|
||||||
|
|
||||||
class _DebouncedValue:
|
class _DebouncedValue:
|
||||||
|
|||||||
@ -68,7 +68,7 @@ class Gpio: # pylint: disable=too-many-instance-attributes
|
|||||||
self.__line_req = gpiod.request_lines(
|
self.__line_req = gpiod.request_lines(
|
||||||
self.__device_path,
|
self.__device_path,
|
||||||
consumer="kvmd::hid",
|
consumer="kvmd::hid",
|
||||||
config=config,
|
config=config, # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
def __exit__(
|
def __exit__(
|
||||||
|
|||||||
@ -153,7 +153,7 @@ class _SpiPhy(BasePhy): # pylint: disable=too-many-instance-attributes
|
|||||||
)
|
)
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def __sw_cs_connected(self) -> Generator[(Callable[[bool], bool] | None), None, None]:
|
def __sw_cs_connected(self) -> Generator[(Callable[[bool], None] | None), None, None]:
|
||||||
if self.__sw_cs_pin > 0:
|
if self.__sw_cs_pin > 0:
|
||||||
with gpiod.request_lines(
|
with gpiod.request_lines(
|
||||||
self.__gpio_device_path,
|
self.__gpio_device_path,
|
||||||
|
|||||||
@ -6,3 +6,4 @@ pyrad
|
|||||||
types-PyYAML
|
types-PyYAML
|
||||||
types-aiofiles
|
types-aiofiles
|
||||||
luma.oled
|
luma.oled
|
||||||
|
gpiod>=2.3
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user