Skip to content

Commit 16a8fd0

Browse files
authored
Merge pull request #3147 from zoldalma999/misc-fixes
Fix stubcheck error on windows, mark typealiases as such in typing
2 parents 1a57252 + 022f3b3 commit 16a8fd0

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

buildconfig/stubs/pygame/geometry.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ from typing import (
1010

1111
from pygame import Rect, FRect
1212
from pygame.typing import Point, RectLike, SequenceLike
13-
from .rect import Rect, FRect
1413
from .math import Vector2
1514

1615
_CanBeCircle = Union[Circle, Tuple[Point, float], SequenceLike[float]]

buildconfig/stubs/pygame/typing.pyi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ __all__ = [
1414

1515
import sys
1616
from abc import abstractmethod
17-
from typing import IO, Callable, Tuple, Union, TypeVar, Protocol
17+
from typing import IO, Callable, Tuple, Union, TypeVar, Protocol, TypeAlias
1818

1919
if sys.version_info >= (3, 9):
2020
from os import PathLike as _PathProtocol
@@ -27,9 +27,9 @@ else:
2727

2828

2929
# For functions that take a file name
30-
_PathLike = Union[str, bytes, _PathProtocol[str], _PathProtocol[bytes]]
30+
_PathLike: TypeAlias = Union[str, bytes, _PathProtocol[str], _PathProtocol[bytes]]
3131
# Most pygame functions that take a file argument should be able to handle a FileLike type
32-
FileLike = Union[_PathLike, IO[bytes], IO[str]]
32+
FileLike: TypeAlias = Union[_PathLike, IO[bytes], IO[str]]
3333

3434
_T_co = TypeVar("_T_co", covariant=True)
3535

@@ -49,11 +49,11 @@ class SequenceLike(Protocol[_T_co]):
4949

5050
# Pygame handles float without errors in most cases where a point is expected,
5151
# usually rounding to int. Also, 'Union[int, float] == float'
52-
Point = SequenceLike[float]
52+
Point: TypeAlias = SequenceLike[float]
5353
# This is used where ints are strictly required
54-
IntPoint = SequenceLike[int]
54+
IntPoint: TypeAlias = SequenceLike[int]
5555

56-
ColorLike = Union[int, str, SequenceLike[int]]
56+
ColorLike: TypeAlias = Union[int, str, SequenceLike[int]]
5757

5858

5959
class _HasRectAttribute(Protocol):
@@ -63,8 +63,8 @@ class _HasRectAttribute(Protocol):
6363
def rect(self) -> Union["RectLike", Callable[[], "RectLike"]]: ...
6464

6565

66-
RectLike = Union[SequenceLike[float], SequenceLike[Point], _HasRectAttribute]
66+
RectLike: TypeAlias = Union[SequenceLike[float], SequenceLike[Point], _HasRectAttribute]
6767

6868

6969
# cleanup namespace
70-
del sys, abstractmethod, IO, Callable, Tuple, Union, TypeVar, Protocol
70+
del sys, abstractmethod, IO, Callable, Tuple, Union, TypeVar, Protocol, TypeAlias

src_py/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@
4848
except (FileNotFoundError, ValueError):
4949
pass
5050

51+
d = "" # define variable here so that we can consistently delete it
5152
for d in dll_parents:
5253
# adding to PATH is the legacy way, os.add_dll_directory is the new
5354
# and recommended method. For extra safety we do both
5455
os.environ["PATH"] = os.environ["PATH"] + ";" + d
5556
os.add_dll_directory(d)
5657

5758
# cleanup namespace
58-
del pygame_dir, dll_parents
59+
del pygame_dir, dll_parents, d
5960

6061
# when running under X11, always set the SDL window WM_CLASS to make the
6162
# window managers correctly match the pygame window.

src_py/typing.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import sys
1616
from abc import abstractmethod
17-
from typing import IO, Callable, Tuple, Union, TypeVar, Protocol
17+
from typing import IO, Callable, Tuple, Union, TypeVar, Protocol, TypeAlias
1818

1919
if sys.version_info >= (3, 9):
2020
from os import PathLike as _PathProtocol
@@ -27,9 +27,9 @@ def __fspath__(self) -> _AnyStr_co: ...
2727

2828

2929
# For functions that take a file name
30-
_PathLike = Union[str, bytes, _PathProtocol[str], _PathProtocol[bytes]]
30+
_PathLike: TypeAlias = Union[str, bytes, _PathProtocol[str], _PathProtocol[bytes]]
3131
# Most pygame functions that take a file argument should be able to handle a FileLike type
32-
FileLike = Union[_PathLike, IO[bytes], IO[str]]
32+
FileLike: TypeAlias = Union[_PathLike, IO[bytes], IO[str]]
3333

3434
_T_co = TypeVar("_T_co", covariant=True)
3535

@@ -49,11 +49,11 @@ def __len__(self) -> int: ...
4949

5050
# Pygame handles float without errors in most cases where a point is expected,
5151
# usually rounding to int. Also, 'Union[int, float] == float'
52-
Point = SequenceLike[float]
52+
Point: TypeAlias = SequenceLike[float]
5353
# This is used where ints are strictly required
54-
IntPoint = SequenceLike[int]
54+
IntPoint: TypeAlias = SequenceLike[int]
5555

56-
ColorLike = Union[int, str, SequenceLike[int]]
56+
ColorLike: TypeAlias = Union[int, str, SequenceLike[int]]
5757

5858

5959
class _HasRectAttribute(Protocol):
@@ -63,8 +63,8 @@ class _HasRectAttribute(Protocol):
6363
def rect(self) -> Union["RectLike", Callable[[], "RectLike"]]: ...
6464

6565

66-
RectLike = Union[SequenceLike[float], SequenceLike[Point], _HasRectAttribute]
66+
RectLike: TypeAlias = Union[SequenceLike[float], SequenceLike[Point], _HasRectAttribute]
6767

6868

6969
# cleanup namespace
70-
del sys, abstractmethod, IO, Callable, Tuple, Union, TypeVar, Protocol
70+
del sys, abstractmethod, IO, Callable, Tuple, Union, TypeVar, Protocol, TypeAlias

0 commit comments

Comments
 (0)