Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use python 3.8 isms in the type stubs #2995

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions buildconfig/stubs/pygame/_common.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from os import PathLike
from typing import IO, Callable, Tuple, Union, TypeVar

from typing_extensions import Literal as Literal, SupportsIndex as SupportsIndex
from typing_extensions import Protocol
from typing import IO, Callable, Tuple, Union, TypeVar, Protocol, SupportsIndex

# For functions that take a file name
AnyPath = Union[str, bytes, PathLike[str], PathLike[bytes]]
Expand Down
4 changes: 2 additions & 2 deletions buildconfig/stubs/pygame/color.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from typing import Any, Dict, Iterator, Tuple, Union, overload
from typing import Any, Dict, Iterator, SupportsIndex, Tuple, Union, overload

from ._common import ColorValue, SupportsIndex
from ._common import ColorValue

if sys.version_info >= (3, 9):
from collections.abc import Collection
Expand Down
4 changes: 2 additions & 2 deletions buildconfig/stubs/pygame/cursors.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Any, Iterator, Tuple, Union, overload
from typing import Any, Iterator, Literal, Tuple, Union, overload

from pygame.surface import Surface

from ._common import FileArg, Literal, IntCoordinate, Sequence
from ._common import FileArg, IntCoordinate, Sequence

_Small_string = Tuple[
str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str
Expand Down
4 changes: 2 additions & 2 deletions buildconfig/stubs/pygame/font.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Callable, Hashable, Iterable, List, Optional, Tuple, Union
from typing import Callable, Hashable, Iterable, List, Literal, Optional, Tuple, Union

from pygame.surface import Surface

from ._common import ColorValue, FileArg, Literal
from ._common import ColorValue, FileArg

# TODO: Figure out a way to type this attribute such that mypy knows it's not
# always defined at runtime
Expand Down
4 changes: 2 additions & 2 deletions buildconfig/stubs/pygame/image.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Optional, Tuple, Union
from typing import Literal, Optional, Tuple, Union

from pygame.bufferproxy import BufferProxy
from pygame.surface import Surface

from ._common import FileArg, Literal, IntCoordinate, Coordinate
from ._common import FileArg, IntCoordinate, Coordinate

_BufferStyle = Union[BufferProxy, bytes, bytearray, memoryview]
_to_string_format = Literal[
Expand Down
3 changes: 2 additions & 1 deletion buildconfig/stubs/pygame/math.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from typing import (
Iterator,
List,
Literal,
SupportsIndex,
Tuple,
Type,
TypeVar,
Expand All @@ -19,7 +20,7 @@ if sys.version_info >= (3, 9):
else:
from typing import Collection

from ._common import SupportsIndex, Sequence
from ._common import Sequence

def clamp(value: float, min: float, max: float, /) -> float: ...

Expand Down
3 changes: 1 addition & 2 deletions buildconfig/stubs/pygame/mouse.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Tuple, overload
from typing_extensions import Literal
from typing import Literal, Tuple, overload
from pygame.cursors import Cursor
from pygame.surface import Surface

Expand Down
4 changes: 2 additions & 2 deletions buildconfig/stubs/pygame/pixelcopy.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Literal

import numpy

from pygame.surface import Surface

from ._common import Literal

_kind = Literal["P", "p", "R", "r", "G", "g", "B", "b", "A", "a", "C", "c"]

def surface_to_array(
Expand Down
4 changes: 3 additions & 1 deletion buildconfig/stubs/pygame/rect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import sys
from typing import (
Dict,
List,
Literal,
SupportsIndex,
Tuple,
TypeVar,
Union,
Expand All @@ -10,7 +12,7 @@ from typing import (
Optional,
)

from ._common import Coordinate, Literal, RectValue, SupportsIndex, Sequence
from ._common import Coordinate, RectValue, Sequence

if sys.version_info >= (3, 11):
from typing import Self
Expand Down
4 changes: 1 addition & 3 deletions buildconfig/stubs/pygame/sprite.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ from typing import (
Iterator,
List,
Optional,
Protocol,
SupportsFloat,
Tuple,
TypeVar,
Union,
)

# Protocol added in python 3.8
from typing_extensions import Protocol

from pygame.rect import FRect, Rect
from pygame.surface import Surface
from pygame.mask import Mask
Expand Down
3 changes: 1 addition & 2 deletions buildconfig/stubs/pygame/surface.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Iterable, List, Optional, Tuple, Union, overload
from typing import Any, Iterable, List, Literal, Optional, Tuple, Union, overload

from pygame.bufferproxy import BufferProxy
from pygame.color import Color
Expand All @@ -7,7 +7,6 @@ from pygame.rect import FRect, Rect
from ._common import (
ColorValue,
Coordinate,
Literal,
RectValue,
RGBAOutput,
Sequence,
Expand Down
4 changes: 1 addition & 3 deletions buildconfig/stubs/pygame/system.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from typing import List, Optional, final

from typing_extensions import TypedDict
from typing import List, Optional, TypedDict

from pygame._data_classes import PowerState

Expand Down
4 changes: 1 addition & 3 deletions buildconfig/stubs/pygame/version.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from typing import Tuple

from ._common import Literal
from typing import Literal, Tuple

class SoftwareVersion(Tuple[int, int, int]):
def __new__(cls, major: int, minor: int, patch: int) -> SoftwareVersion: ...
Expand Down
Loading