Fixed some mypy errors
This commit is contained in:
@@ -253,6 +253,11 @@ class SublimeMusicApp(Gtk.Application):
|
|||||||
return
|
return
|
||||||
offset_seconds = offset / second_microsecond_conversion
|
offset_seconds = offset / second_microsecond_conversion
|
||||||
new_seconds = self.state.song_progress + offset_seconds
|
new_seconds = self.state.song_progress + offset_seconds
|
||||||
|
|
||||||
|
# This should not ever happen. The current_song should always have
|
||||||
|
# a duration, but the Child object has `duration` optional because
|
||||||
|
# it could be a directory.
|
||||||
|
assert self.state.current_song.duration is not None
|
||||||
self.on_song_scrub(
|
self.on_song_scrub(
|
||||||
None, new_seconds / self.state.current_song.duration * 100)
|
None, new_seconds / self.state.current_song.duration * 100)
|
||||||
|
|
||||||
@@ -713,6 +718,10 @@ class SublimeMusicApp(Gtk.Application):
|
|||||||
if not self.state.current_song or not self.window:
|
if not self.state.current_song or not self.window:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# This should not ever happen. The current_song should always have
|
||||||
|
# a duration, but the Child object has `duration` optional because
|
||||||
|
# it could be a directory.
|
||||||
|
assert self.state.current_song.duration is not None
|
||||||
new_time = self.state.current_song.duration * (scrub_value / 100)
|
new_time = self.state.current_song.duration * (scrub_value / 100)
|
||||||
|
|
||||||
self.state.song_progress = new_time
|
self.state.song_progress = new_time
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
import functools
|
import functools
|
||||||
import re
|
import re
|
||||||
from concurrent.futures import Future
|
from concurrent.futures import Future
|
||||||
from typing import Any, Callable, cast, Iterable, List, Match, Tuple, Union
|
from typing import (
|
||||||
|
Any, Callable, cast, Iterable, List, Match, Optional, Tuple, Union)
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
from deepdiff import DeepDiff
|
from deepdiff import DeepDiff
|
||||||
@@ -13,7 +14,7 @@ from sublime.server.api_objects import Playlist
|
|||||||
from sublime.state_manager import ApplicationState
|
from sublime.state_manager import ApplicationState
|
||||||
|
|
||||||
|
|
||||||
def format_song_duration(duration_secs: int) -> str:
|
def format_song_duration(duration_secs: Optional[int]) -> str:
|
||||||
"""
|
"""
|
||||||
Formats the song duration as mins:seconds with the seconds being
|
Formats the song duration as mins:seconds with the seconds being
|
||||||
zero-padded if necessary.
|
zero-padded if necessary.
|
||||||
@@ -23,6 +24,9 @@ def format_song_duration(duration_secs: int) -> str:
|
|||||||
>>> format_song_duration(62)
|
>>> format_song_duration(62)
|
||||||
'1:02'
|
'1:02'
|
||||||
"""
|
"""
|
||||||
|
if not duration_secs:
|
||||||
|
return '-:--'
|
||||||
|
|
||||||
return f'{duration_secs // 60}:{duration_secs % 60:02}'
|
return f'{duration_secs // 60}:{duration_secs % 60:02}'
|
||||||
|
|
||||||
|
|
||||||
@@ -80,9 +84,9 @@ def format_sequence_duration(duration_secs: int) -> str:
|
|||||||
return ', '.join(format_components)
|
return ', '.join(format_components)
|
||||||
|
|
||||||
|
|
||||||
def esc(string: str) -> str:
|
def esc(string: Optional[str]) -> str:
|
||||||
if string is None:
|
if string is None:
|
||||||
return None
|
return ''
|
||||||
return string.replace('&', '&').replace(" target='_blank'", '')
|
return string.replace('&', '&').replace(" target='_blank'", '')
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user