Skip to content

Commit 0aded36

Browse files
committed
Remove _SupportsSprite and _SupportsDirtySprite protocols
1 parent ecbf7bd commit 0aded36

File tree

1 file changed

+6
-44
lines changed

1 file changed

+6
-44
lines changed

buildconfig/stubs/pygame/sprite.pyi

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -46,42 +46,7 @@ class _HasMaskAndRect(_HasRect, Protocol):
4646
# non-generic Group, used in Sprite
4747
_Group = AbstractGroup[Any]
4848

49-
# protocol helps with structural subtyping for typevars in sprite group generics
50-
# and allows the use of any class with the required attributes and methods
51-
class _SupportsSprite(_HasImageAndRect, Protocol):
52-
@property
53-
def image(self) -> Optional[Surface]: ...
54-
@image.setter
55-
def image(self, value: Optional[Surface]) -> None: ...
56-
@property
57-
def rect(self) -> Optional[Union[FRect, Rect]]: ...
58-
@rect.setter
59-
def rect(self, value: Optional[Union[FRect, Rect]]) -> None: ...
60-
@property
61-
def layer(self) -> int: ...
62-
@layer.setter
63-
def layer(self, value: int) -> None: ...
64-
def add_internal(self, group: _Group) -> None: ...
65-
def remove_internal(self, group: _Group) -> None: ...
66-
def update(self, *args: Any, **kwargs: Any) -> None: ...
67-
def add(self, *groups: _GroupOrGroups[Any]) -> None: ...
68-
def remove(self, *groups: _GroupOrGroups[Any]) -> None: ...
69-
def kill(self) -> None: ...
70-
def alive(self) -> bool: ...
71-
def groups(self) -> list[_Group]: ...
72-
73-
# also a protocol
74-
class _SupportsDirtySprite(_SupportsSprite, Protocol):
75-
dirty: int
76-
blendmode: int
77-
source_rect: Union[FRect, Rect]
78-
visible: int
79-
_layer: int
80-
def _set_visible(self, val: int) -> None: ...
81-
def _get_visible(self) -> int: ...
82-
83-
# concrete sprite implementation class
84-
class Sprite(_SupportsSprite):
49+
class Sprite:
8550
@property
8651
def image(self) -> Optional[Surface]: ...
8752
@image.setter
@@ -102,10 +67,9 @@ class Sprite(_SupportsSprite):
10267
def remove(self, *groups: _GroupOrGroups[Any]) -> None: ...
10368
def kill(self) -> None: ...
10469
def alive(self) -> bool: ...
105-
def groups(self) -> list[AbstractGroup[_SupportsSprite]]: ...
70+
def groups(self) -> list[AbstractGroup[Sprite]]: ...
10671

107-
# concrete dirty sprite implementation class
108-
class DirtySprite(Sprite, _SupportsDirtySprite):
72+
class DirtySprite(Sprite):
10973
dirty: int
11074
blendmode: int
11175
source_rect: Union[FRect, Rect]
@@ -114,11 +78,9 @@ class DirtySprite(Sprite, _SupportsDirtySprite):
11478
def _set_visible(self, val: int) -> None: ...
11579
def _get_visible(self) -> int: ...
11680

117-
# typevar bound to Sprite, _SupportsSprite Protocol ensures sprite
118-
# subclass passed to group has image and rect attributes
119-
_TSprite = TypeVar("_TSprite", bound=_SupportsSprite)
120-
_TSprite2 = TypeVar("_TSprite2", bound=_SupportsSprite)
121-
_TDirtySprite = TypeVar("_TDirtySprite", bound=_SupportsDirtySprite)
81+
_TSprite = TypeVar("_TSprite", bound=Sprite)
82+
_TSprite2 = TypeVar("_TSprite2", bound=Sprite)
83+
_TDirtySprite = TypeVar("_TDirtySprite", bound=DirtySprite)
12284

12385
_GroupOrGroups = Union[AbstractGroup[_TSprite], Iterable[_GroupOrGroups[_TSprite]]]
12486
_SpriteOrSprites = Union[_TSprite, Iterable[_SpriteOrSprites[_TSprite]]]

0 commit comments

Comments
 (0)