From 745cd1d6d3d6227d2a1e82cf25611d76221c40cd Mon Sep 17 00:00:00 2001 From: decorator-factory <42166884+decorator-factory@users.noreply.github.com> Date: Sat, 7 Aug 2021 05:23:03 +0300 Subject: Fix type annotations --- bot/exts/evergreen/minesweeper.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'bot/exts/evergreen/minesweeper.py') diff --git a/bot/exts/evergreen/minesweeper.py b/bot/exts/evergreen/minesweeper.py index 932358f9..75d13d88 100644 --- a/bot/exts/evergreen/minesweeper.py +++ b/bot/exts/evergreen/minesweeper.py @@ -1,7 +1,8 @@ import logging -import typing +from collections.abc import Iterator from dataclasses import dataclass from random import randint, random +from typing import Union import discord from discord.ext import commands @@ -33,7 +34,7 @@ MESSAGE_MAPPING = { log = logging.getLogger(__name__) -GameBoard = typing.List[typing.List[typing.Union[str, int]]] +GameBoard = list[list[Union[str, int]]] @dataclass @@ -47,14 +48,11 @@ class Game: activated_on_server: bool -GamesDict = typing.Dict[int, Game] - - class Minesweeper(commands.Cog): """Play a game of Minesweeper.""" def __init__(self) -> None: - self.games: GamesDict = {} # Store the currently running games + self.games: dict[int, Game] = {} @commands.group(name="minesweeper", aliases=("ms",), invoke_without_command=True) async def minesweeper_group(self, ctx: commands.Context) -> None: @@ -62,7 +60,7 @@ class Minesweeper(commands.Cog): await invoke_help_command(ctx) @staticmethod - def get_neighbours(x: int, y: int) -> typing.Generator[typing.Tuple[int, int], None, None]: + def get_neighbours(x: int, y: int) -> Iterator[tuple[int, int]]: """Get all the neighbouring x and y including it self.""" for x_ in [x - 1, x, x + 1]: for y_ in [y - 1, y, y + 1]: -- cgit v1.2.3