Skip to content

Commit

Permalink
fix some mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed Aug 18, 2024
1 parent 135b2d5 commit a93bf6d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 5 additions & 3 deletions feeluown/library/ytdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def match_rule(self, url, source=''):
def select_audio(self, url, _: Optional[str] = None, source='') -> Optional[Media]:
matched_rule = self.match_rule(url, source)
if matched_rule is None:
return
return None
http_proxy = matched_rule.get('http_proxy')
ytdl_opts = {}
ytdl_opts.update(self._default_audio_ytdl_opts)
Expand All @@ -71,7 +71,7 @@ def select_audio(self, url, _: Optional[str] = None, source='') -> Optional[Medi
def select_video(self, url, _: Optional[str] = None, source='') -> Optional[Media]:
matched_rule = self.match_rule(url, source)
if matched_rule is None:
return
return None
http_proxy = matched_rule.get('http_proxy')
ytdl_opts = {}
ytdl_opts.update(self._default_video_ytdl_opts)
Expand All @@ -91,7 +91,7 @@ def select_video(self, url, _: Optional[str] = None, source='') -> Optional[Medi
):
video_candidates.append((f['url'], f['width']))
if not (audio_candidates and video_candidates):
return
return None
audio_candidates = sorted(
audio_candidates, key=lambda c: c[1] or 0, reverse=True
)
Expand Down Expand Up @@ -123,5 +123,7 @@ def select_video(self, url, _: Optional[str] = None, source='') -> Optional[Medi
# print()

media = ytdl.select_video(url, None, 'ytmusic')
assert media is not None
assert isinstance(media.manifest, VideoAudioManifest)
print(media.manifest.video_url)
print(media.manifest.audio_url)
8 changes: 4 additions & 4 deletions feeluown/player/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ def current_song(self) -> Optional[SongModel]:
"""
return self._current_song

@current_song.setter
def current_song(self, song: Optional[SongModel]):
self.set_current_song(song)

@property
def current_song_mv(self) -> Optional[VideoModel]:
return self._current_song_mv
Expand Down Expand Up @@ -707,10 +711,6 @@ def set_current_model(self, model) -> asyncio.Task:
self.a_set_current_model, model, name=TASK_SET_CURRENT_MODEL,
)

@current_song.setter
def current_song(self, song: Optional[SongModel]):
self.set_current_song(song)

def set_current_song(self, song):
"""
.. versionadded:: 3.7.11
Expand Down
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ ignore = E402
max-line-length = 89
exclude = feeluown/mpv.py

[mypy]
disable_error_code = import-untyped

[yapf]
column_limit = 89
based_on_style = pep8
Expand Down Expand Up @@ -39,3 +42,7 @@ addopts = -q
--doctest-modules
[mypy-feeluown.mpv]
ignore_errors = True

# I don't know how to type hint mixin class which is related to PyQt5.
[mypy-feeluown.gui.helpers]
ignore_errors = True

0 comments on commit a93bf6d

Please sign in to comment.