Skip to content

Commit 1155cf8

Browse files
committed
Use TypedDict where possible
1 parent 84c4407 commit 1155cf8

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
from typing import Union, Optional
1+
from typing import TypedDict, Optional
2+
3+
# dict at runtime, this only exist for benefit of the typechecker
4+
class _FingerDict(TypedDict):
5+
id: int
6+
x: float
7+
y: float
8+
pressure: float
29

310
def get_num_devices() -> int: ...
411
def get_device(index: int, /) -> int: ...
512
def get_num_fingers(device_id: int, /) -> int: ...
6-
def get_finger(touchid: int, index: int) -> Optional[dict[str, Union[int, float]]]: ...
13+
def get_finger(touchid: int, index: int) -> Optional[_FingerDict]: ...

buildconfig/stubs/pygame/mixer_music.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
from typing import Optional
1+
from typing import Optional, TypedDict
22

33
from pygame.typing import FileLike
44

5+
class _MusicMetadataDict(TypedDict):
6+
title: str
7+
album: str
8+
artist: str
9+
copyright: str
10+
511
def load(filename: FileLike, namehint: Optional[str] = "") -> None: ...
612
def unload() -> None: ...
713
def play(loops: int = 0, start: float = 0.0, fade_ms: int = 0) -> None: ...
@@ -18,4 +24,6 @@ def get_pos() -> int: ...
1824
def queue(filename: FileLike, namehint: str = "", loops: int = 0) -> None: ...
1925
def set_endevent(event_type: int, /) -> None: ...
2026
def get_endevent() -> int: ...
21-
def get_metadata(filename: Optional[FileLike] = None, namehint: str = "") -> dict[str, str]: ...
27+
def get_metadata(
28+
filename: Optional[FileLike] = None, namehint: str = ""
29+
) -> _MusicMetadataDict: ...

0 commit comments

Comments
 (0)