1
0

feat: update legacy

This commit is contained in:
2026-06-16 19:57:15 +08:00
parent 1c81b24f74
commit 480e11dbf4
3 changed files with 252 additions and 35 deletions

View File

@@ -2,7 +2,7 @@ import enum
from functools import cached_property
from dataclasses import dataclass
from typing import Iterator
from .common import DeviceKind, Circuit
from common import DeviceKind, Circuit
class ResponsePriority(enum.Enum):
@@ -103,7 +103,9 @@ class Response:
"""
The collection of possible solutions given by the resolver.
For getting the response items, please use the iterator protocol.
For getting the response items, please use `response[index]`.
For iterating the response items, please use the iterator protocol.
For getting the count of response items, please use the ``len`` function.
"""
__sorted_items: list[ResponseItem]
@@ -125,5 +127,11 @@ class Response:
# Cut item by limit
self.__sorted_items = self.__sorted_items[:request.count_limit]
def __getitem__(self, index: int) -> ResponseItem:
return self.__sorted_items[index]
def __len__(self) -> int:
return len(self.__sorted_items)
def __iter__(self) -> Iterator[ResponseItem]:
return iter(self.__sorted_items)