Fix some types in cocoa.py so they work with the stubs

This commit is contained in:
Danielle McLean 2023-11-27 16:52:00 +11:00
parent a673f2ef90
commit 5a3ddd570d
Signed by: 00dani
GPG key ID: 52C059C3B22A753E

View file

@ -58,11 +58,12 @@ def ns_image_to_media_item_artwork(img: NSImage) -> MPMediaItemArtwork:
def playback_state_to_cocoa(state: PlaybackState) -> MPMusicPlaybackState: def playback_state_to_cocoa(state: PlaybackState) -> MPMusicPlaybackState:
return { mapping: dict[PlaybackState, MPMusicPlaybackState] = {
PlaybackState.play: MPMusicPlaybackStatePlaying, PlaybackState.play: MPMusicPlaybackStatePlaying,
PlaybackState.pause: MPMusicPlaybackStatePaused, PlaybackState.pause: MPMusicPlaybackStatePaused,
PlaybackState.stop: MPMusicPlaybackStateStopped, PlaybackState.stop: MPMusicPlaybackStateStopped,
}[state] }
return mapping[state]
def song_to_media_item(song: Song) -> NSMutableDictionary: def song_to_media_item(song: Song) -> NSMutableDictionary:
@ -139,7 +140,7 @@ class CocoaNowPlaying:
def _create_handler( def _create_handler(
self, player: Callable[[], Coroutine[None, None, PlaybackState | None]] self, player: Callable[[], Coroutine[None, None, PlaybackState | None]]
) -> Callable[[MPRemoteCommandEvent], None]: ) -> Callable[[MPRemoteCommandEvent], MPRemoteCommandHandlerStatus]:
async def invoke_music_player() -> None: async def invoke_music_player() -> None:
result = await player() result = await player()
if result: if result: