Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Cleanup: Replace direct calling of dunder methods on objects #4584

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,13 +1070,13 @@ def __init__(self, region_manager: MultiWorld.RegionManager):
self.region_manager = region_manager

def __getitem__(self, index: int) -> Location:
return self._list.__getitem__(index)
return self._list[index]

def __setitem__(self, index: int, value: Location) -> None:
raise NotImplementedError()

def __len__(self) -> int:
return self._list.__len__()
return len(self._list)

# This seems to not be needed, but that's a bit suspicious.
# def __del__(self):
Expand All @@ -1087,8 +1087,8 @@ def copy(self):

class LocationRegister(Register):
def __delitem__(self, index: int) -> None:
location: Location = self._list.__getitem__(index)
self._list.__delitem__(index)
location: Location = self._list[index]
del self._list[index]
del(self.region_manager.location_cache[location.player][location.name])

def insert(self, index: int, value: Location) -> None:
Expand All @@ -1099,8 +1099,8 @@ def insert(self, index: int, value: Location) -> None:

class EntranceRegister(Register):
def __delitem__(self, index: int) -> None:
entrance: Entrance = self._list.__getitem__(index)
self._list.__delitem__(index)
entrance: Entrance = self._list[index]
del self._list[index]
del(self.region_manager.entrance_cache[entrance.player][entrance.name])

def insert(self, index: int, value: Entrance) -> None:
Expand Down
2 changes: 1 addition & 1 deletion CommonClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def __iter__(self) -> typing.Iterator[str]:
return iter(self._game_store)

def __repr__(self) -> str:
return self._game_store.__repr__()
return repr(self._game_store)

def lookup_in_game(self, code: int, game_name: typing.Optional[str] = None) -> str:
"""Returns the name for an item/location id in the context of a specific game or own game if `game` is
Expand Down
12 changes: 6 additions & 6 deletions Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,13 +858,13 @@ def get_option_name(self, value):
return ", ".join(f"{key}: {v}" for key, v in value.items())

def __getitem__(self, item: str) -> typing.Any:
return self.value.__getitem__(item)
return self.value[item]

def __iter__(self) -> typing.Iterator[str]:
return self.value.__iter__()
return iter(self.value)

def __len__(self) -> int:
return self.value.__len__()
return len(self.value)


class ItemDict(OptionDict):
Expand Down Expand Up @@ -1026,10 +1026,10 @@ def __iter__(self) -> typing.Iterator[PlandoText]:
yield from self.value

def __getitem__(self, index: typing.SupportsIndex) -> PlandoText:
return self.value.__getitem__(index)
return self.value[index]

def __len__(self) -> int:
return self.value.__len__()
return len(self.value)


class ConnectionsMeta(AssembleOptions):
Expand Down Expand Up @@ -1176,7 +1176,7 @@ def get_option_name(cls, value: typing.List[PlandoConnection]) -> str:
connection.exit) for connection in value])

def __getitem__(self, index: typing.SupportsIndex) -> PlandoConnection:
return self.value.__getitem__(index)
return self.value[index]

def __iter__(self) -> typing.Iterator[PlandoConnection]:
yield from self.value
Expand Down
Loading