Skip to content

Commit

Permalink
style: update black to target 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewADev committed Aug 20, 2023
1 parent 36d738f commit 1f89c09
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
pipenv install --dev
- name: Check formatting
run: pipenv run black --target-version=py310 .
run: pipenv run black --target-version=py311 .

- name: Check types
run: pipenv run mypy rps rps-sim.py
Expand Down
12 changes: 8 additions & 4 deletions rps-sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
from rps.game import play_games



@click.command
@click.option("--games", default=3, type=click.IntRange(min=1, max=1000), help="Number of games to play")
@click.option(
"--games",
default=3,
type=click.IntRange(min=1, max=1000),
help="Number of games to play",
)
@click.option("--p1-name", default="Player 1", help="Name of first player")
@click.option("--p2-name", default="Player 2", help="Name of second player")
def simple_sim(games: int, p1_name: str, p2_name: str) -> None:
Expand All @@ -22,5 +26,5 @@ def simple_sim(games: int, p1_name: str, p2_name: str) -> None:
print("Simulation finished.")


if __name__ == '__main__':
simple_sim()
if __name__ == "__main__":
simple_sim()
5 changes: 4 additions & 1 deletion rps/game.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from .player import Player
from .play import PlayResult


def play_game(firstPlayer: Player, secondPlayer: Player) -> PlayResult:
firstPlay = firstPlayer.play()
secondPlay = secondPlayer.play()
return firstPlay.match(secondPlay)


def play_games(firstPlayer: Player, secondPlayer: Player, times: int) -> list[PlayResult]:
def play_games(
firstPlayer: Player, secondPlayer: Player, times: int
) -> list[PlayResult]:
results = []
for _ in range(times):
results.append(play_game(firstPlayer, secondPlayer))
Expand Down
2 changes: 1 addition & 1 deletion rps/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ def __init__(self, play_strategy: PlaySelectionStrategy, name: str = "Bot Player
self.__strategy = play_strategy
self.name = name

def play(self) -> Play:
def play(self) -> Play:
return self.__strategy.play()

0 comments on commit 1f89c09

Please sign in to comment.