Skip to content

Commit

Permalink
Fix pyre issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hsahovic committed Nov 11, 2021
1 parent 16294bd commit 9475eaf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/poke_env/environment/abstract_battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def _finish_battle(self) -> None:

self._finished = True

def _parse_message(self, split_message: List[str]) -> None: # pyre-ignore
def _parse_message(self, split_message: List[str]) -> None:
if self._save_replays:
self._replay_data.append(split_message)

Expand Down Expand Up @@ -584,8 +584,8 @@ def _parse_message(self, split_message: List[str]) -> None: # pyre-ignore
pokemon, item = split_message[2:4]
self.get_pokemon(pokemon).item = to_id_str(item)
elif split_message[1] == "-mega":
if not split_message[2].startswith(self._player_role):
self._opponent_can_mega_evolve = False
if not split_message[2].startswith(self._player_role): # pyre-ignore
self._opponent_can_mega_evolve = False # pyre-ignore
pokemon, megastone = split_message[2:4]
self.get_pokemon(pokemon)._mega_evolve(megastone)
elif split_message[1] == "-mustrecharge":
Expand Down Expand Up @@ -629,8 +629,8 @@ def _parse_message(self, split_message: List[str]) -> None: # pyre-ignore
pokemon, into = split_message[2:4]
self.get_pokemon(pokemon)._transform(self.get_pokemon(into))
elif split_message[1] == "-zpower":
if not split_message[2].startswith(self._player_role):
self._opponent_can_mega_z_move = False
if not split_message[2].startswith(self._player_role): # pyre-ignore
self._opponent_can_mega_z_move = False # pyre-ignore

pokemon = split_message[2]
self.get_pokemon(pokemon)._used_z_move()
Expand Down
2 changes: 1 addition & 1 deletion src/poke_env/environment/battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def opponent_can_z_move(self) -> bool:

@opponent_can_z_move.setter
def opponent_can_z_move(self, value: bool) -> None:
self._opponentcan_z_move = value
self._opponent_can_z_move = value

@property
def trapped(self) -> bool:
Expand Down
12 changes: 7 additions & 5 deletions src/poke_env/teambuilder/teambuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def yield_team(self) -> str: # pragma: no cover
"""Returns a packed-format team."""

@staticmethod
def parse_showdown_team(team: str) -> List[TeambuilderPokemon]: # pyre-ignore
def parse_showdown_team(team: str) -> List[TeambuilderPokemon]:
"""Converts a showdown-formatted team string into a list of TeambuilderPokemon
objects.
Expand All @@ -37,14 +37,15 @@ def parse_showdown_team(team: str) -> List[TeambuilderPokemon]: # pyre-ignore
:return: The formatted team.
:rtype: list of TeambuilderPokemon
"""
current_mon = None
current_mon = TeambuilderPokemon()
current_mon_has_been_added = True
mons = []

for line in team.split("\n"):
if line == "":
if current_mon is not None:
if not current_mon_has_been_added:
mons.append(current_mon)
current_mon = None
current_mon_has_been_added = True
elif line.startswith("Ability"):
ability = line.replace("Ability: ", "")
current_mon.ability = ability.strip()
Expand Down Expand Up @@ -87,6 +88,7 @@ def parse_showdown_team(team: str) -> List[TeambuilderPokemon]: # pyre-ignore
current_mon.hiddenpowertype = hp_type
else:
current_mon = TeambuilderPokemon()
current_mon_has_been_added = False
if "@" in line:
mon_info, item = line.split(" @ ")
current_mon.item = item.strip()
Expand All @@ -108,7 +110,7 @@ def parse_showdown_team(team: str) -> List[TeambuilderPokemon]: # pyre-ignore
break
current_mon.nickname = " ".join(split_mon_info)
current_mon.nickname = " ".join(split_mon_info)
if current_mon is not None:
if not current_mon_has_been_added:
mons.append(current_mon)
return mons

Expand Down

0 comments on commit 9475eaf

Please sign in to comment.