diff --git a/CommonClient.py b/CommonClient.py index b622fb93..51791100 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -196,25 +196,11 @@ class CommonContext: self.lookup_type: typing.Literal["item", "location"] = lookup_type self._unknown_item: typing.Callable[[int], str] = lambda key: f"Unknown {lookup_type} (ID: {key})" self._archipelago_lookup: typing.Dict[int, str] = {} - self._flat_store: typing.Dict[int, str] = Utils.KeyedDefaultDict(self._unknown_item) self._game_store: typing.Dict[str, typing.ChainMap[int, str]] = collections.defaultdict( lambda: collections.ChainMap(self._archipelago_lookup, Utils.KeyedDefaultDict(self._unknown_item))) - self.warned: bool = False # noinspection PyTypeChecker def __getitem__(self, key: str) -> typing.Mapping[int, str]: - # TODO: In a future version (0.6.0?) this should be simplified by removing implicit id lookups support. - if isinstance(key, int): - if not self.warned: - # Use warnings instead of logger to avoid deprecation message from appearing on user side. - self.warned = True - warnings.warn(f"Implicit name lookup by id only is deprecated and only supported to maintain " - f"backwards compatibility for now. If multiple games share the same id for a " - f"{self.lookup_type}, name could be incorrect. Please use " - f"`{self.lookup_type}_names.lookup_in_game()` or " - f"`{self.lookup_type}_names.lookup_in_slot()` instead.") - return self._flat_store[key] # type: ignore - return self._game_store[key] def __len__(self) -> int: @@ -254,7 +240,6 @@ class CommonContext: id_to_name_lookup_table = Utils.KeyedDefaultDict(self._unknown_item) id_to_name_lookup_table.update({code: name for name, code in name_to_id_lookup_table.items()}) self._game_store[game] = collections.ChainMap(self._archipelago_lookup, id_to_name_lookup_table) - self._flat_store.update(id_to_name_lookup_table) # Only needed for legacy lookup method. if game == "Archipelago": # Keep track of the Archipelago data package separately so if it gets updated in a custom datapackage, # it updates in all chain maps automatically. diff --git a/test/programs/test_common_client.py b/test/programs/test_common_client.py index 9936240d..eeeba9d4 100644 --- a/test/programs/test_common_client.py +++ b/test/programs/test_common_client.py @@ -47,17 +47,6 @@ class TestCommonContext(unittest.IsolatedAsyncioTestCase): assert "Archipelago" in self.ctx.item_names, "Archipelago item names entry does not exist" assert "Archipelago" in self.ctx.location_names, "Archipelago location names entry does not exist" - async def test_implicit_name_lookups(self): - # Items - assert self.ctx.item_names[2**54 + 1] == "Test Item 1 - Safe" - assert self.ctx.item_names[2**54 + 3] == f"Unknown item (ID: {2**54+3})" - assert self.ctx.item_names[-1] == "Nothing" - - # Locations - assert self.ctx.location_names[2**54 + 1] == "Test Location 1 - Safe" - assert self.ctx.location_names[2**54 + 3] == f"Unknown location (ID: {2**54+3})" - assert self.ctx.location_names[-1] == "Cheat Console" - async def test_explicit_name_lookups(self): # Items assert self.ctx.item_names["__TestGame1"][2**54+1] == "Test Item 1 - Safe"