22
33import json
44import re
5- from collections import OrderedDict
65from collections .abc import (
76 Callable ,
87 Iterable ,
@@ -224,7 +223,7 @@ def get(self, index: int) -> HistoryItem:
224223 #
225224 spanpattern = re .compile (r'^\s*(?P<start>-?[1-9]\d*)?(?P<separator>:|(\.{2,}))(?P<end>-?[1-9]\d*)?\s*$' )
226225
227- def span (self , span : str , include_persisted : bool = False ) -> 'OrderedDict [int, HistoryItem]' :
226+ def span (self , span : str , include_persisted : bool = False ) -> dict [int , ' HistoryItem' ] :
228227 """Return a slice of the History list.
229228
230229 :param span: string containing an index or a slice
@@ -273,7 +272,7 @@ def span(self, span: str, include_persisted: bool = False) -> 'OrderedDict[int,
273272
274273 return self ._build_result_dictionary (start , end )
275274
276- def str_search (self , search : str , include_persisted : bool = False ) -> 'OrderedDict [int, HistoryItem]' :
275+ def str_search (self , search : str , include_persisted : bool = False ) -> dict [int , ' HistoryItem' ] :
277276 """Find history items which contain a given string.
278277
279278 :param search: the string to search for
@@ -292,7 +291,7 @@ def isin(history_item: HistoryItem) -> bool:
292291 start = 0 if include_persisted else self .session_start_index
293292 return self ._build_result_dictionary (start , len (self ), isin )
294293
295- def regex_search (self , regex : str , include_persisted : bool = False ) -> 'OrderedDict [int, HistoryItem]' :
294+ def regex_search (self , regex : str , include_persisted : bool = False ) -> dict [int , ' HistoryItem' ] :
296295 """Find history items which match a given regular expression.
297296
298297 :param regex: the regular expression to search for.
@@ -328,13 +327,13 @@ def truncate(self, max_length: int) -> None:
328327
329328 def _build_result_dictionary (
330329 self , start : int , end : int , filter_func : Callable [[HistoryItem ], bool ] | None = None
331- ) -> 'OrderedDict [int, HistoryItem]' :
330+ ) -> dict [int , ' HistoryItem' ] :
332331 """Build history search results.
333332
334333 :param start: start index to search from
335334 :param end: end index to stop searching (exclusive).
336335 """
337- results : OrderedDict [int , HistoryItem ] = OrderedDict ()
336+ results : dict [int , HistoryItem ] = {}
338337 for index in range (start , end ):
339338 if filter_func is None or filter_func (self [index ]):
340339 results [index + 1 ] = self [index ]
0 commit comments