44
55import warnings
66from collections import defaultdict
7- from typing import TYPE_CHECKING , Any , DefaultDict , Dict , Final , Iterable , Mapping , NoReturn , Set , TypeVar
7+ from collections .abc import Iterable , Mapping
8+ from typing import TYPE_CHECKING , Any , Final , NoReturn , TypeVar
89
910import attrs
1011from typing_extensions import deprecated
@@ -195,23 +196,23 @@ def __setstate__(self, state: dict[str, Any]) -> None:
195196 # Apply defaultdict types to unpickled dictionaries
196197 self ._components_by_type = converter .structure (
197198 state .pop ("_components_by_type" ),
198- DefaultDict [Any , Dict [Any , Any ]],
199+ defaultdict [Any , dict [Any , Any ]],
199200 )
200201 self ._components_by_entity = _components_by_entity_from (self ._components_by_type )
201202
202203 self ._tags_by_entity = converter .structure (
203204 state .pop ("_tags_by_entity" ),
204- DefaultDict [Any , Set [Any ]],
205+ defaultdict [Any , set [Any ]],
205206 )
206207 self ._tags_by_key = _tags_by_key_from_tags_by_entity (self ._tags_by_entity )
207208
208209 self ._relation_tags_by_entity = converter .structure (
209210 state .pop ("_relation_tags_by_entity" ),
210- DefaultDict [Any , DefaultDict [Any , Set [Any ]]],
211+ defaultdict [Any , defaultdict [Any , set [Any ]]],
211212 )
212213 self ._relation_components_by_entity = converter .structure (
213214 state .pop ("_relation_components_by_entity" ),
214- DefaultDict [Any , DefaultDict [Any , Dict [Any , Any ]]],
215+ defaultdict [Any , defaultdict [Any , dict [Any , Any ]]],
215216 )
216217 self ._relations_lookup = _relations_lookup_from (
217218 self ._relation_tags_by_entity , self ._relation_components_by_entity
@@ -231,11 +232,11 @@ def __getstate__(self) -> dict[str, Any]:
231232 converter = tcod .ecs ._converter ._get_converter ()
232233 # Replace defaultdict types with plain dict when saving
233234 return {
234- "_components_by_type" : converter .structure (self ._components_by_type , Dict [Any , Dict [Any , Any ]]),
235- "_tags_by_entity" : converter .structure (self ._tags_by_entity , Dict [Any , Any ]),
236- "_relation_tags_by_entity" : converter .structure (self ._relation_tags_by_entity , Dict [Any , Dict [Any , Any ]]),
235+ "_components_by_type" : converter .structure (self ._components_by_type , dict [Any , dict [Any , Any ]]),
236+ "_tags_by_entity" : converter .structure (self ._tags_by_entity , dict [Any , Any ]),
237+ "_relation_tags_by_entity" : converter .structure (self ._relation_tags_by_entity , dict [Any , dict [Any , Any ]]),
237238 "_relation_components_by_entity" : converter .structure (
238- self ._relation_components_by_entity , Dict [Any , Dict [Any , Any ]]
239+ self ._relation_components_by_entity , dict [Any , dict [Any , Any ]]
239240 ),
240241 "_names_by_name" : self ._names_by_name ,
241242 }
0 commit comments