Skip to content

Commit a11fba3

Browse files
committed
Add typed dictionary for Result
1 parent bb5e749 commit a11fba3

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

pyflowlauncher/result.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,20 @@ class PreviewInfo(TypedDict):
3636
PreviewDeligate: Optional[str]
3737

3838

39-
@dataclass
40-
class Result:
39+
class Result(TypedDict):
40+
"""Result Item"""
4141
Title: str
42-
SubTitle: Optional[str] = None
43-
IcoPath: Optional[Union[str, Path]] = None
44-
Score: int = 0
45-
JsonRPCAction: Optional[JsonRPCAction] = None
46-
ContextData: Optional[Iterable] = None
47-
Glyph: Optional[Glyph] = None
48-
CopyText: Optional[str] = None
49-
AutoCompleteText: Optional[str] = None
50-
RoundedIcon: bool = False
51-
Preview: Optional[PreviewInfo] = None
52-
TitleHighlightData: Optional[List[int]] = None
53-
54-
def as_dict(self) -> Dict[str, Any]:
55-
return self.__dict__
56-
57-
def add_action(self, method: Method,
58-
parameters: Optional[Iterable[Any]] = None,
59-
*,
60-
dont_hide_after_action: bool = False) -> None:
61-
self.JsonRPCAction = {
62-
"method": method.__name__,
63-
"parameters": parameters or [],
64-
"dontHideAfterAction": dont_hide_after_action
65-
}
42+
SubTitle: NotRequired[str]
43+
IcoPath: NotRequired[Union[str, Path]]
44+
Score: NotRequired[int]
45+
JsonRPCAction: NotRequired[JsonRPCAction]
46+
ContextData: NotRequired[Iterable]
47+
Glyph: NotRequired[Glyph]
48+
CopyText: NotRequired[str]
49+
AutoCompleteText: NotRequired[str]
50+
RoundedIcon: NotRequired[bool]
51+
Preview: NotRequired[PreviewInfo]
52+
TitleHighlightData: NotRequired[List[int]]
6653

6754

6855
class ResultResponse(TypedDict):

0 commit comments

Comments
 (0)