@@ -109,7 +109,7 @@ def _clean_attribute(
109109
110110def _clean_attribute_value (
111111 value : types .AttributeValue , limit : Optional [int ]
112- ) -> Union [types .AttributeValue , None ]:
112+ ) -> Optional [types .AttributeValue ]:
113113 if value is None :
114114 return None
115115
@@ -149,20 +149,20 @@ def __init__(
149149 self .max_value_len = max_value_len
150150 # OrderedDict is not used until the maxlen is reached for efficiency.
151151
152- self ._dict : dict | OrderedDict = {}
152+ self ._dict : MutableMapping [ str , types . AttributeValue ] | OrderedDict [ str , types . AttributeValue ] = {}
153153 self ._lock = threading .RLock ()
154154 if attributes :
155155 for key , value in attributes .items ():
156156 self [key ] = value
157157 self ._immutable = immutable
158158
159159 def __repr__ (self ) -> str :
160- return f"{ dict (self ._dict )} " # type: ignore
160+ return f"{ dict (self ._dict )} "
161161
162- def __getitem__ (self , key ): # type: ignore
163- return self ._dict [key ] # type: ignore
162+ def __getitem__ (self , key : str ) -> types . AttributeValue :
163+ return self ._dict [key ]
164164
165- def __setitem__ (self , key , value ): # type: ignore
165+ def __setitem__ (self , key : str , value : types . AttributeValue ) -> None :
166166 if getattr (self , "_immutable" , False ): # type: ignore
167167 raise TypeError
168168 with self ._lock :
@@ -171,24 +171,24 @@ def __setitem__(self, key, value): # type: ignore
171171 return
172172
173173 value = _clean_attribute (key , value , self .max_value_len ) # type: ignore
174- if value is not None : # type: ignore
175- if key in self ._dict : # type: ignore
176- del self ._dict [key ] # type: ignore
174+ if value is not None :
175+ if key in self ._dict :
176+ del self ._dict [key ]
177177 elif (
178- self .maxlen is not None and len (self ._dict ) == self .maxlen # type: ignore
178+ self .maxlen is not None and len (self ._dict ) == self .maxlen
179179 ):
180- if not isinstance (self ._dict , OrderedDict ): # type: ignore
181- self ._dict = OrderedDict (self ._dict ) # type: ignore
182- self ._dict .popitem (last = False )
180+ if not isinstance (self ._dict , OrderedDict ):
181+ self ._dict = OrderedDict (self ._dict )
182+ self ._dict .popitem (last = False ) # type: ignore
183183 self .dropped += 1
184184
185- self ._dict [key ] = value # type: ignore
185+ self ._dict [key ] = value # type: ignore
186186
187- def __delitem__ (self , key ) -> None :
187+ def __delitem__ (self , key : str ) -> None :
188188 if getattr (self , "_immutable" , False ): # type: ignore
189189 raise TypeError
190190 with self ._lock :
191- del self ._dict [key ] # type: ignore
191+ del self ._dict [key ]
192192
193193 def __iter__ (self ): # type: ignore
194194 with self ._lock :
0 commit comments