Skip to content

Commit 80d1a84

Browse files
authored
Merge pull request #77 from mopidy/enable-pyright
2 parents 7a8ea69 + 7d97a02 commit 80d1a84

File tree

6 files changed

+20
-15
lines changed

6 files changed

+20
-15
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727
python: "3.14"
2828
tox: "3.14"
2929
coverage: true
30-
# - name: "pyright"
31-
# python: "3.14"
32-
# tox: "pyright"
30+
- name: "pyright"
31+
python: "3.14"
32+
tox: "pyright"
3333
- name: "ruff check"
3434
python: "3.14"
3535
tox: "ruff-check"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ classifiers = [
1414
]
1515
dynamic = ["version"]
1616
dependencies = [
17-
"mopidy >= 4.0.0a8",
17+
"mopidy >= 4.0.0a10",
1818
"pygobject >= 3.50",
1919
"pykka >= 4.1",
2020
]

src/mopidy_mpd/network.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
from typing import TYPE_CHECKING, Any, Never
1212

1313
import pykka
14-
from gi.repository import GLib # pyright: ignore[reportMissingModuleSource]
14+
from gi.repository import (
15+
GLib, # pyright: ignore[reportAttributeAccessIssue, reportMissingModuleSource]
16+
)
1517

1618
logger = logging.getLogger(__name__)
1719

src/mopidy_mpd/protocol/current_playlist.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from typing import TYPE_CHECKING
44
from urllib.parse import urlparse
55

6+
from mopidy.types import TracklistId
7+
68
from mopidy_mpd import exceptions, protocol, translator
79

810
if TYPE_CHECKING:
@@ -153,7 +155,7 @@ def moveid(context: MpdContext, tlid: int, to: int) -> None:
153155
the playlist. If ``TO`` is negative, it is relative to the current
154156
song in the playlist (if there is one).
155157
"""
156-
position = context.core.tracklist.index(tlid=tlid).get()
158+
position = context.core.tracklist.index(tlid=TracklistId(tlid)).get()
157159
if position is None:
158160
raise exceptions.MpdNoExistError("No such song")
159161
context.core.tracklist.move(position, position + 1, to)
@@ -428,8 +430,8 @@ def swapid(context: MpdContext, tlid1: int, tlid2: int) -> None:
428430
429431
Swaps the positions of ``SONG1`` and ``SONG2`` (both song ids).
430432
"""
431-
position1 = context.core.tracklist.index(tlid=tlid1).get()
432-
position2 = context.core.tracklist.index(tlid=tlid2).get()
433+
position1 = context.core.tracklist.index(tlid=TracklistId(tlid1)).get()
434+
position2 = context.core.tracklist.index(tlid=TracklistId(tlid2)).get()
433435
if position1 is None or position2 is None:
434436
raise exceptions.MpdNoExistError("No such song")
435437
swap(context, position1, position2)

src/mopidy_mpd/protocol/music_db.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def _artist_as_track(artist: Artist) -> Track:
9898
return Track(
9999
uri=artist.uri,
100100
name=f"Artist: {artist.name}",
101-
artists=[artist],
101+
artists=frozenset([artist]),
102102
)
103103

104104

@@ -192,7 +192,7 @@ def findadd(context: MpdContext, *args: str) -> None:
192192
return
193193

194194
results = context.core.library.search(query=query, exact=True).get()
195-
uris = [track.uri for track in _get_tracks(results)]
195+
uris = [track.uri for track in _get_tracks(results) if track.uri is not None]
196196
context.core.tracklist.add(uris=uris).get()
197197

198198

@@ -498,8 +498,8 @@ def searchadd(context: MpdContext, *args: str) -> None:
498498
return
499499

500500
results = context.core.library.search(query).get()
501-
502-
context.core.tracklist.add(uris=[track.uri for track in _get_tracks(results)]).get()
501+
uris = [track.uri for track in _get_tracks(results) if track.uri is not None]
502+
context.core.tracklist.add(uris=uris).get()
503503

504504

505505
@protocol.commands.add("searchaddpl")

src/mopidy_mpd/protocol/stored_playlists.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def listplaylist(context: MpdContext, name: str) -> protocol.Result:
6565
file: relative/path/to/file3.mp3
6666
"""
6767
playlist = _get_playlist(context, name, must_exist=True)
68-
return [("file", track.uri) for track in playlist.tracks]
68+
return [("file", track.uri) for track in playlist.tracks if track.uri is not None]
6969

7070

7171
@protocol.commands.add("listplaylistinfo")
@@ -83,7 +83,7 @@ def listplaylistinfo(context: MpdContext, name: str) -> protocol.Result:
8383
Album, Artist, Track
8484
"""
8585
playlist = _get_playlist(context, name, must_exist=True)
86-
track_uris = [track.uri for track in playlist.tracks]
86+
track_uris = [track.uri for track in playlist.tracks if track.uri is not None]
8787
tracks_map = context.core.library.lookup(uris=track_uris).get()
8888
tracks = []
8989
for uri in track_uris:
@@ -180,7 +180,7 @@ def load(
180180
"tuple[Track]",
181181
playlist.tracks[playlist_slice], # pyright: ignore[reportIndexIssue]
182182
)
183-
track_uris = [track.uri for track in tracks]
183+
track_uris = [track.uri for track in tracks if track.uri is not None]
184184
context.core.tracklist.add(uris=track_uris).get()
185185

186186

@@ -358,6 +358,7 @@ def rename(context: MpdContext, old_name: str, new_name: str) -> None:
358358
_check_playlist_name(new_name)
359359

360360
old_playlist = _get_playlist(context, old_name, must_exist=True)
361+
assert old_playlist.uri
361362

362363
if _get_playlist(context, new_name, must_exist=False):
363364
raise exceptions.MpdExistError("Playlist already exists")

0 commit comments

Comments
 (0)