Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-finley committed Mar 18, 2024
1 parent 0d5853c commit 11697b6
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/lichess.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

MAX_CHAT_MESSAGE_LEN = 140 # The maximum characters in a chat message.


class OKResponse(TypedDict):
"""Often given by the API on POSTs or endpoints needing no further action."""
ok: bool
Expand Down Expand Up @@ -268,8 +269,10 @@ def make_move(self, game_id: str, move: chess.engine.PlayResult) -> OKResponse:
:param game_id: The id of the game.
:param move: The move to make.
"""
return cast(OKResponse, self.api_post("move", game_id, move.move,
params={"offeringDraw": str(move.draw_offered).lower()}))
return cast(OKResponse, self.api_post(
"move", game_id, move.move,
params={"offeringDraw": str(move.draw_offered).lower()}
))

def chat(self, game_id: str, room: str, text: str) -> OKResponse:
"""
Expand Down Expand Up @@ -309,11 +312,12 @@ def accept_challenge(self, challenge_id: str) -> OKResponse:
def decline_challenge(self, challenge_id: str, reason: str = "generic") -> OKResponse:
"""Decline a challenge."""
try:
return cast(OKResponse, self.api_post("decline", challenge_id,
data=f"reason={reason}",
headers={"Content-Type":
"application/x-www-form-urlencoded"},
raise_for_status=False))
return cast(OKResponse, self.api_post(
"decline", challenge_id,
data=f"reason={reason}",
headers={"Content-Type": "application/x-www-form-urlencoded"},
raise_for_status=False
))
except Exception:
return {"ok": False}

Expand Down

0 comments on commit 11697b6

Please sign in to comment.