Skip to content

Commit

Permalink
remove white spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannSab committed Jun 6, 2024
1 parent 4d3722d commit 72de01d
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 26 deletions.
18 changes: 9 additions & 9 deletions gen_ref_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
import mkdocs_gen_files
import re

for path in sorted(Path("src").rglob("*.py")): #
for path in sorted(Path("src").rglob("*.py")): #
if len(re.findall('(^|/)__',str(path))):
continue

module_path = path.relative_to("src").with_suffix("") #
doc_path = path.relative_to("src").with_suffix(".md") #
full_doc_path = Path("reference", doc_path) #
module_path = path.relative_to("src").with_suffix("") #
doc_path = path.relative_to("src").with_suffix(".md") #
full_doc_path = Path("reference", doc_path) #

parts = list(module_path.parts)

if parts[-1] == "__init__": #
if parts[-1] == "__init__": #
parts = parts[:-1]
elif parts[-1] == "__main__":
continue

with mkdocs_gen_files.open(full_doc_path, "w") as fd: #
identifier = ".".join(parts) #
print("::: " + identifier, file=fd) #
with mkdocs_gen_files.open(full_doc_path, "w") as fd: #
identifier = ".".join(parts) #
print("::: " + identifier, file=fd) #

mkdocs_gen_files.set_edit_path(full_doc_path, path) #
mkdocs_gen_files.set_edit_path(full_doc_path, path) #
6 changes: 3 additions & 3 deletions src/seahorse/game/game_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get_possible_light_actions(self) -> frozenset[LightAction]:
if self._possible_light_actions is None:
self._possible_light_actions = frozenset(self.generate_possible_light_actions())
return self._possible_light_actions

def get_possible_heavy_actions(self) -> frozenset[HeavyAction]:
"""
Returns a copy of the possible heavy actions from this state.
Expand Down Expand Up @@ -171,7 +171,7 @@ def apply_action(self, action: LightAction) -> "GameState":
MethodNotImplementedError: If the method is not implemented.
"""
raise MethodNotImplementedError()

@abstractmethod
def generate_possible_light_actions(self) -> set[LightAction]:
"""
Expand All @@ -184,7 +184,7 @@ def generate_possible_light_actions(self) -> set[LightAction]:
MethodNotImplementedError: If the method is not implemented.
"""
raise MethodNotImplementedError()

@abstractmethod
def generate_possible_heavy_actions(self) -> set[HeavyAction]:
"""
Expand Down
3 changes: 1 addition & 2 deletions src/seahorse/game/heavy_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import TYPE_CHECKING

from seahorse.game.action import Action
from seahorse.utils.serializer import Serializable

if TYPE_CHECKING:
from seahorse.game.game_state import GameState
Expand Down Expand Up @@ -47,7 +46,7 @@ def get_next_game_state(self) -> GameState:
"""
return self.next_game_state

def get_heavy_action(self, game_state: GameState = None) -> HeavyAction:
def get_heavy_action(self, **_) -> HeavyAction:
"""
Returns the heavy action.
Expand Down
2 changes: 1 addition & 1 deletion src/seahorse/game/io_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ async def wait_for_event(self,sid:int,label:str,*,flush_until:float | None=None)
flush_until (float, optional): The timestamp treshold. Defaults to None.
Returns:
Coroutine: a promise yielding the data associated to the event
Coroutine: a promise yielding the data associated to the event
"""
while not len(self.__events.get(sid,{}).get(label,[])):
await asyncio.sleep(.1)
Expand Down
8 changes: 4 additions & 4 deletions src/seahorse/game/light_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def __init__(self, data: dict) -> None:
Initializes a new instance of the Action class.
Args: data (dict): The data of the light action.
"""
self.data = data


def get_heavy_action(self, game_state: GameState = None) -> HeavyAction:
"""
Returns the heavy action.
Expand All @@ -36,9 +36,9 @@ def get_heavy_action(self, game_state: GameState = None) -> HeavyAction:
"""
if game_state is None:
raise ValueError("Cannot apply a light action without current game state.")

Check failure on line 38 in src/seahorse/game/light_action.py

View workflow job for this annotation

GitHub Actions / Linting (3.9)

Ruff (EM101)

src/seahorse/game/light_action.py:38:30: EM101 Exception must not use a string literal, assign to variable first

return HeavyAction(game_state, game_state.apply_action(self))


def __hash__(self) -> int:
return hash(tuple(self.data.items()))
Expand Down
6 changes: 3 additions & 3 deletions src/seahorse/game/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async def step(self) -> GameState:
self.remaining_time[next_player.get_id()] -= (tstp-start)
if self.remaining_time[next_player.get_id()] < 0:
raise SeahorseTimeoutError()

# if abs((tstp-start)-(tstp-next_player.get_last_timestamp()))>self.timetol:
# next_player.stop_timer()
# raise StopAndStartError()
Expand Down Expand Up @@ -146,7 +146,7 @@ async def play_game(self) -> list[Player]:
self.current_game_state = await self.step()

# self.recorded_plays.append(self.current_game_state.__class__.from_json(json.dumps(self.current_game_state.to_json(),default=lambda x:x.to_json())))

except (ActionNotPermittedError,SeahorseTimeoutError,StopAndStartError) as e:
if isinstance(e,SeahorseTimeoutError):
logger.error(f"Time credit expired for player {self.current_game_state.get_next_player()}")
Expand Down Expand Up @@ -201,7 +201,7 @@ async def play_game(self) -> list[Player]:
await self.emitter.sio.emit("done",json.dumps(self.get_scores()))
logger.verdict(f"{','.join(w.get_name() for w in self.get_winner())} has won the game")

print(f"Time taken for the whole game : {time.time()-time_start}")
print(f"Time taken for the whole game : {time.time()-time_start}")

Check failure on line 204 in src/seahorse/game/master.py

View workflow job for this annotation

GitHub Actions / Linting (3.9)

Ruff (T201)

src/seahorse/game/master.py:204:9: T201 `print` found

return self.winner

Expand Down
2 changes: 1 addition & 1 deletion src/seahorse/player/proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def to_json(self) -> dict:
return self.wrapped_player.to_json()

class InteractivePlayerProxy(LocalPlayerProxy):
"""Proxy for interactive players,
"""Proxy for interactive players,
inherits from `LocalPlayerProxy`
"""
def __init__(self, mimics: Player, gui_path:Optional[str]=None, *args, **kwargs) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/seahorse/utils/gui_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Any, Coroutine, Optional

from loguru import logger
from seahorse.game.io_stream import EventMaster, EventSlave
from seahorse.game.io_stream import EventMaster, EventSlave

class GUIClient(EventSlave):
def __init__(self, path:Optional[str]=None) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/seahorse/utils/recorders.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class StateRecorder(EventSlave):
"""

def __init__(self) -> None:
super().__init__()
super().__init__()
self.identifier = "__REC__"+str(int(time.time()*1000000-random.randint(1,1000000)))
self.id = builtins.id(self)
self.wrapped_id = self.id
Expand All @@ -22,7 +22,7 @@ def __init__(self) -> None:

@self.sio.on("play")
def record_play(data):
self.recorded_content.append(json.loads(data))
self.recorded_content.append(json.loads(data))

@self.sio.event()
def disconnect():
Expand Down

0 comments on commit 72de01d

Please sign in to comment.