From 259f24951d27bdfcb5d7b3f54f1f420ca44b71ef Mon Sep 17 00:00:00 2001 From: Jesse Farebrother Date: Wed, 19 Apr 2023 12:03:30 -0400 Subject: [PATCH] Change @typing.overload -> @overload for Python stubs This fixes a problem with pytype where it checks hardcoded decorators and only includes `@overload` and not `@typing.overload`. --- src/python/__init__.pyi | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/python/__init__.pyi b/src/python/__init__.pyi index f05f58fc1..d1c619727 100644 --- a/src/python/__init__.pyi +++ b/src/python/__init__.pyi @@ -1,6 +1,5 @@ import os -import typing -from typing import List, Optional +from typing import List, Optional, overload import numpy as np import numpy.typing as npt @@ -84,11 +83,11 @@ class Action: class ALEState: def __eq__(self, other: ALEState) -> bool: ... def __getstate__(self) -> tuple: ... - @typing.overload + @overload def __init__(self) -> None: ... - @typing.overload + @overload def __init__(self, state: ALEState, serialized: str) -> None: ... - @typing.overload + @overload def __init__(self, serialized: str) -> None: ... def __setstate__(self, state: tuple) -> None: ... def equals(self, other: ALEState) -> bool: ... @@ -102,9 +101,9 @@ class ALEState: class ALEInterface: def __init__(self) -> None: ... - @typing.overload + @overload def act(self, action: Action) -> int: ... - @typing.overload + @overload def act(self, action: int) -> int: ... def cloneState(self, *, include_rng: bool = False) -> ALEState: ... def cloneSystemState(self) -> ALEState: ... @@ -119,35 +118,35 @@ class ALEInterface: def getInt(self, key: str) -> int: ... def getLegalActionSet(self) -> List[Action]: ... def getMinimalActionSet(self) -> List[Action]: ... - @typing.overload + @overload def getRAM(self) -> npt.NDArray[np.uint8]: ... - @typing.overload + @overload def getRAM(self, arg0: npt.NDArray[np.uint8]) -> None: ... def getRAMSize(self) -> int: ... - @typing.overload + @overload def getScreen(self) -> npt.NDArray[np.uint8]: ... - @typing.overload + @overload def getScreen(self, array: npt.NDArray[np.uint8]) -> None: ... def getScreenDims(self) -> tuple: ... - @typing.overload + @overload def getScreenGrayscale(self) -> npt.NDArray[np.uint8]: ... - @typing.overload + @overload def getScreenGrayscale(self, array: npt.NDArray[np.uint8]) -> None: ... - @typing.overload + @overload def getScreenRGB(self) -> npt.NDArray[np.uint8]: ... - @typing.overload + @overload def getScreenRGB(self, array: npt.NDArray[np.uint8]) -> None: ... def getString(self, key: str) -> str: ... @staticmethod - @typing.overload + @overload def isSupportedROM(rom: os.PathLike) -> Optional[str]: ... @staticmethod - @typing.overload + @overload def isSupportedROM(rom: str) -> Optional[str]: ... def lives(self) -> int: ... - @typing.overload + @overload def loadROM(self, rom: os.PathLike) -> None: ... - @typing.overload + @overload def loadROM(self, rom: str) -> None: ... def reset_game(self) -> None: ... def restoreState(self, state: ALEState) -> None: ...