8
8
9
9
if TYPE_CHECKING :
10
10
from pathlib import Path
11
- from typing import Any , Generator , Mapping
11
+ from typing import Any , Iterator , Mapping
12
12
13
13
from typing_extensions import Self , TypeAlias
14
14
@@ -87,8 +87,8 @@ def similar_keys(self, key: str, replaces: CompiledReplaces) -> list[str]:
87
87
"""
88
88
return self ._similar_keys ("" , key , self .dct .ROOT , replaces )
89
89
90
- @classmethod
91
- def compile_replaces (cls , replaces : Replaces ) -> CompiledReplaces :
90
+ @staticmethod
91
+ def compile_replaces (replaces : Replaces ) -> CompiledReplaces :
92
92
for k , v in replaces .items ():
93
93
if len (k ) != 1 :
94
94
msg = "Keys must be single-char unicode strings."
@@ -130,7 +130,6 @@ class CompletionDAWG(DAWG):
130
130
DAWG with key completion support.
131
131
"""
132
132
133
- dct : wrapper .Dictionary
134
133
guide : wrapper .Guide | None
135
134
136
135
def __init__ (self ) -> None :
@@ -140,7 +139,7 @@ def __init__(self) -> None:
140
139
def keys (self , prefix : str = "" ) -> list [str ]:
141
140
return list (self .iterkeys (prefix ))
142
141
143
- def iterkeys (self , prefix : str = "" ) -> Generator [str , None , None ]:
142
+ def iterkeys (self , prefix : str = "" ) -> Iterator [str ]:
144
143
b_prefix = prefix .encode ("utf8" )
145
144
index = self .dct .follow_bytes (b_prefix , self .dct .ROOT )
146
145
if index is None :
@@ -179,7 +178,7 @@ class BytesDAWG(CompletionDAWG):
179
178
{unicode -> list of bytes objects} mapping.
180
179
"""
181
180
182
- def __init__ (self , payload_separator : bytes | None = PAYLOAD_SEPARATOR ) -> None :
181
+ def __init__ (self , payload_separator : bytes = PAYLOAD_SEPARATOR ) -> None :
183
182
super ().__init__ ()
184
183
self ._payload_separator = payload_separator
185
184
@@ -236,7 +235,7 @@ def b_get_value(self, b_key: bytes) -> list[bytes]:
236
235
def keys (self , prefix : str | bytes = "" ) -> list [str ]:
237
236
return list (self .iterkeys (prefix ))
238
237
239
- def iterkeys (self , prefix : str | bytes = "" ) -> Generator [bytes , None , None ]:
238
+ def iterkeys (self , prefix : str | bytes = "" ) -> Iterator [bytes ]:
240
239
if not isinstance (prefix , bytes ):
241
240
prefix = prefix .encode ("utf8" )
242
241
@@ -258,7 +257,7 @@ def iterkeys(self, prefix: str | bytes = "") -> Generator[bytes, None, None]:
258
257
def items (self , prefix : str | bytes = "" ) -> list [tuple [str , bytes ]]:
259
258
return list (self .iteritems (prefix ))
260
259
261
- def iteritems (self , prefix : str | bytes = "" ) -> Generator [tuple [str , bytes ], None , None ]:
260
+ def iteritems (self , prefix : str | bytes = "" ) -> Iterator [tuple [str , bytes ]]:
262
261
if not isinstance (prefix , bytes ):
263
262
prefix = prefix .encode ("utf8" )
264
263
@@ -394,7 +393,7 @@ def _value_for_index(self, index: int) -> list[tuple[Any, ...]]:
394
393
def items (self , prefix : str | bytes = "" ) -> list [tuple [str , tuple [Any , ...]]]:
395
394
return list (self .iteritems (prefix ))
396
395
397
- def iteritems (self , prefix : str | bytes = "" ) -> Generator [tuple [str , tuple [Any , ...]], None , None ]:
396
+ def iteritems (self , prefix : str | bytes = "" ) -> Iterator [tuple [str , tuple [Any , ...]]]:
398
397
res = super ().iteritems (prefix )
399
398
return ((key , self ._struct .unpack (val )) for (key , val ) in res )
400
399
@@ -438,7 +437,7 @@ class IntCompletionDAWG(CompletionDAWG, IntDAWG):
438
437
def items (self , prefix : str | bytes = "" ) -> list [tuple [str , int ]]:
439
438
return list (self .iteritems (prefix ))
440
439
441
- def iteritems (self , prefix : str | bytes = "" ) -> Generator [tuple [str , int ], None , None ]:
440
+ def iteritems (self , prefix : str | bytes = "" ) -> Iterator [tuple [str , int ]]:
442
441
if not isinstance (prefix , bytes ):
443
442
prefix = prefix .encode ("utf8" )
444
443
index = self .dct .ROOT
0 commit comments