From 418247232c428e96e05e46607faabb86adccc20a Mon Sep 17 00:00:00 2001 From: damusss Date: Fri, 17 Jan 2025 21:19:21 +0100 Subject: [PATCH 1/4] Expand init parameters for window --- buildconfig/stubs/pygame/window.pyi | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/buildconfig/stubs/pygame/window.pyi b/buildconfig/stubs/pygame/window.pyi index ac948b4931..6f1a1f7ec9 100644 --- a/buildconfig/stubs/pygame/window.pyi +++ b/buildconfig/stubs/pygame/window.pyi @@ -1,4 +1,4 @@ -from typing import Optional, Union +from typing import Optional, Union, overload from typing_extensions import deprecated # added in 3.13 from pygame.typing import Point, RectLike @@ -9,6 +9,7 @@ from pygame.surface import Surface def get_grabbed_window() -> Optional[Window]: ... class Window: + @overload def __init__( self, title: str = "pygame window", @@ -16,6 +17,32 @@ class Window: position: Union[int, Point] = WINDOWPOS_UNDEFINED, **flags: bool ) -> None: ... + @overload + def __init__( + self, + title: str = "pygame window", + size: Point = (640, 480), + position: Union[int, Point] = WINDOWPOS_UNDEFINED, + *, + fullscreen: bool = ..., + fullscreen_desktop: bool = ..., + opengl: bool = ..., + vulkan: bool = ..., + hidden: bool = ..., + borderless: bool = ..., + resizable: bool = ..., + minimized: bool = ..., + maximized: bool = ..., + mouse_grabbed: bool = ..., + keyboard_grabbed: bool = ..., + input_focus: bool = ..., + mouse_focus: bool = ..., + allow_high_dpi: bool = ..., + mouse_capture: bool = ..., + always_on_top: bool = ..., + utility: bool = ..., + ): + ... def destroy(self) -> None: ... def set_windowed(self) -> None: ... def set_fullscreen(self, desktop: bool = False) -> None: ... From 90f1440a9e1f4703fb5056a26d9df453c4524328 Mon Sep 17 00:00:00 2001 From: damusss Date: Fri, 17 Jan 2025 21:39:04 +0100 Subject: [PATCH 2/4] Add type ignore --- buildconfig/stubs/pygame/window.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildconfig/stubs/pygame/window.pyi b/buildconfig/stubs/pygame/window.pyi index 6f1a1f7ec9..0267a50fd2 100644 --- a/buildconfig/stubs/pygame/window.pyi +++ b/buildconfig/stubs/pygame/window.pyi @@ -18,7 +18,7 @@ class Window: **flags: bool ) -> None: ... @overload - def __init__( + def __init__( # type: ignore[overload-cannot-match] self, title: str = "pygame window", size: Point = (640, 480), From a1bd732699ef15998c180e0a72c26de536964537 Mon Sep 17 00:00:00 2001 From: damusss Date: Mon, 20 Jan 2025 13:54:06 +0100 Subject: [PATCH 3/4] Remove the overload --- buildconfig/stubs/pygame/window.pyi | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/buildconfig/stubs/pygame/window.pyi b/buildconfig/stubs/pygame/window.pyi index 0267a50fd2..3c6fd05b08 100644 --- a/buildconfig/stubs/pygame/window.pyi +++ b/buildconfig/stubs/pygame/window.pyi @@ -1,4 +1,4 @@ -from typing import Optional, Union, overload +from typing import Optional, Union from typing_extensions import deprecated # added in 3.13 from pygame.typing import Point, RectLike @@ -9,16 +9,7 @@ from pygame.surface import Surface def get_grabbed_window() -> Optional[Window]: ... class Window: - @overload def __init__( - self, - title: str = "pygame window", - size: Point = (640, 480), - position: Union[int, Point] = WINDOWPOS_UNDEFINED, - **flags: bool - ) -> None: ... - @overload - def __init__( # type: ignore[overload-cannot-match] self, title: str = "pygame window", size: Point = (640, 480), From 075d959131bffa99d4f1c7d117037053cb6f2e06 Mon Sep 17 00:00:00 2001 From: Damiano <97639432+damusss@users.noreply.github.com> Date: Mon, 20 Jan 2025 20:06:23 +0100 Subject: [PATCH 4/4] update return value hinting Co-authored-by: Ankith --- buildconfig/stubs/pygame/window.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/buildconfig/stubs/pygame/window.pyi b/buildconfig/stubs/pygame/window.pyi index 3c6fd05b08..c341ae4fca 100644 --- a/buildconfig/stubs/pygame/window.pyi +++ b/buildconfig/stubs/pygame/window.pyi @@ -32,8 +32,7 @@ class Window: mouse_capture: bool = ..., always_on_top: bool = ..., utility: bool = ..., - ): - ... + ) -> None: ... def destroy(self) -> None: ... def set_windowed(self) -> None: ... def set_fullscreen(self, desktop: bool = False) -> None: ...