mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
fix lint issues with latest mypy_protobuf
This commit is contained in:
parent
263bfb2e8e
commit
772c7a945c
2 changed files with 16 additions and 12 deletions
|
@ -426,21 +426,25 @@ class Collection:
|
|||
# the reverse argument only applies when a BuiltinSortKind is provided;
|
||||
# otherwise the collection config defines whether reverse is set or not
|
||||
def find_cards(
|
||||
self, query: str, order: Union[bool, str, int] = False, reverse: bool = False,
|
||||
self,
|
||||
query: str,
|
||||
order: Union[
|
||||
bool,
|
||||
str,
|
||||
pb.BuiltinSearchOrder.BuiltinSortKindValue, # pylint: disable=no-member
|
||||
] = False,
|
||||
reverse: bool = False,
|
||||
) -> Sequence[int]:
|
||||
if isinstance(order, str):
|
||||
mode = pb.SortOrder(custom=order)
|
||||
elif order is True:
|
||||
elif isinstance(order, bool):
|
||||
if order is True:
|
||||
mode = pb.SortOrder(from_config=pb.Empty())
|
||||
elif order is False:
|
||||
else:
|
||||
mode = pb.SortOrder(none=pb.Empty())
|
||||
else:
|
||||
# sadly we can't use the protobuf type in a Union, so we
|
||||
# have to accept an int and convert it
|
||||
BKind = pb.BuiltinSearchOrder.BuiltinSortKind # pylint: disable=no-member
|
||||
kind = BKind.Value(BKind.Name(order))
|
||||
mode = pb.SortOrder(
|
||||
builtin=pb.BuiltinSearchOrder(kind=kind, reverse=reverse)
|
||||
builtin=pb.BuiltinSearchOrder(kind=order, reverse=reverse)
|
||||
)
|
||||
return self.backend.search_cards(search=query, order=mode)
|
||||
|
||||
|
|
|
@ -82,12 +82,12 @@ SyncErrorKind = pb.SyncError.SyncErrorKind
|
|||
|
||||
|
||||
class NetworkError(StringError):
|
||||
def kind(self) -> NetworkErrorKind:
|
||||
def kind(self) -> pb.NetworkError.NetworkErrorKindValue:
|
||||
return self.args[1]
|
||||
|
||||
|
||||
class SyncError(StringError):
|
||||
def kind(self) -> SyncErrorKind:
|
||||
def kind(self) -> pb.SyncError.SyncErrorKindValue:
|
||||
return self.args[1]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue