[gnome-music/wip/mschraal/type-checking: 10/13] CI: Add static type checking pass
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/type-checking: 10/13] CI: Add static type checking pass
- Date: Tue, 16 Jun 2020 20:05:50 +0000 (UTC)
commit fbaccd2ce1084acc7ac85a3c8be08967704589c9
Author: Marinus Schraal <mschraal gnome org>
Date: Sat May 30 14:09:44 2020 +0200
CI: Add static type checking pass
Also:
* Ignore initial propertyerrors
* Add relevant .gitignore
* Add some required types
.gitignore | 1 +
.gitlab-ci.yml | 6 ++++++
gnomemusic/albumartcache.py | 6 ++++--
gnomemusic/artistart.py | 4 +++-
gnomemusic/corealbum.py | 2 +-
gnomemusic/coreartist.py | 6 +++---
gnomemusic/coredisc.py | 2 +-
gnomemusic/coresong.py | 4 ++--
gnomemusic/grilowrappers/grltrackerplaylists.py | 4 ++--
gnomemusic/grilowrappers/grltrackerwrapper.py | 2 +-
gnomemusic/gstplayer.py | 6 +++---
gnomemusic/player.py | 2 +-
gnomemusic/scrobbler.py | 6 +++---
gnomemusic/views/artistsview.py | 2 +-
gnomemusic/views/emptyview.py | 2 +-
gnomemusic/views/searchview.py | 2 +-
gnomemusic/views/songsview.py | 2 +-
gnomemusic/widgets/artistartstack.py | 4 ++--
gnomemusic/widgets/coverstack.py | 2 +-
gnomemusic/widgets/headerbar.py | 6 +++---
gnomemusic/widgets/playertoolbar.py | 2 +-
gnomemusic/widgets/playlistcontrols.py | 4 ++--
gnomemusic/widgets/searchheaderbar.py | 4 ++--
gnomemusic/widgets/smoothscale.py | 2 +-
gnomemusic/widgets/songwidget.py | 6 +++---
gnomemusic/widgets/starhandlerwidget.py | 2 +-
gnomemusic/widgets/starimage.py | 4 ++--
27 files changed, 53 insertions(+), 42 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index cbbcb9ca..3ccde405 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ builddir/
/.dirstamp
/.gitignore
/.libs
+/.mypy_cache/*
/AUTHORS
/ABOUT-NLS
/GPATH
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a484574a..9eea22f4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -28,3 +28,9 @@ flake8:
script:
- dnf install -y python3-flake8
- flake8 --ignore E402,W503 --show-source gnomemusic/
+
+mypy:
+ stage: check
+ script:
+ - dnf install -y python3-mypy
+ - mypy --follow-imports=skip --ignore-missing-imports gnomemusic
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index 6c388711..efe0ce5b 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -24,6 +24,7 @@
from enum import Enum
from math import pi
+from typing import Dict, List, Tuple
import os
import cairo
@@ -122,7 +123,8 @@ class DefaultIcon(GObject.GObject):
LOADING = 'content-loading-symbolic'
MUSIC = 'folder-music-symbolic'
- _cache = {}
+ _cache: Dict[
+ Tuple["DefaultIcon.Type", "Art.Size", int], cairo.Surface] = {}
_default_theme = Gtk.IconTheme.get_default()
def __init__(self):
@@ -170,7 +172,7 @@ class Art(GObject.GObject):
'finished': (GObject.SignalFlags.RUN_FIRST, None, ())
}
- _blacklist = {}
+ _blacklist: Dict[str, List[str]] = {}
class Size(Enum):
"""Enum for icon sizes"""
diff --git a/gnomemusic/artistart.py b/gnomemusic/artistart.py
index 973c5369..b9d5abc5 100644
--- a/gnomemusic/artistart.py
+++ b/gnomemusic/artistart.py
@@ -24,6 +24,7 @@
from enum import Enum
from math import pi
+from typing import Dict, Tuple
import cairo
import gi
@@ -32,6 +33,7 @@ gi.require_version("Soup", "2.4")
from gi.repository import (Gdk, GdkPixbuf, Gio, GLib, GObject, Gtk, MediaArt,
Soup)
+from gnomemusic.albumartcache import Art
from gnomemusic.musiclogger import MusicLogger
@@ -88,7 +90,7 @@ class DefaultIcon(GObject.GObject):
LOADING = "content-loading-symbolic"
ARTIST = "avatar-default-symbolic"
- _cache = {}
+ _cache: Dict[Tuple["DefaultIcon.Type", Art.Size, int], cairo.Surface] = {}
_default_theme = Gtk.IconTheme.get_default()
def __init__(self):
diff --git a/gnomemusic/corealbum.py b/gnomemusic/corealbum.py
index 588001f7..a5f6a1cb 100644
--- a/gnomemusic/corealbum.py
+++ b/gnomemusic/corealbum.py
@@ -113,7 +113,7 @@ class CoreAlbum(GObject.GObject):
def selected(self):
return self._selected
- @selected.setter
+ @selected.setter # type: ignore
def selected(self, value):
if value == self._selected:
return
diff --git a/gnomemusic/coreartist.py b/gnomemusic/coreartist.py
index 9aeccd68..9321e39b 100644
--- a/gnomemusic/coreartist.py
+++ b/gnomemusic/coreartist.py
@@ -94,7 +94,7 @@ class CoreArtist(GObject.GObject):
def selected(self):
return self._selected
- @selected.setter
+ @selected.setter # type: ignore
def selected(self, value):
if value == self._selected:
return
@@ -116,7 +116,7 @@ class CoreArtist(GObject.GObject):
return self._thumbnail
- @thumbnail.setter
+ @thumbnail.setter # type: ignore
def thumbnail(self, value):
self._thumbnail = value
@@ -124,6 +124,6 @@ class CoreArtist(GObject.GObject):
def cached_thumbnail_uri(self):
return self._cached_thumbnail_uri
- @cached_thumbnail_uri.setter
+ @cached_thumbnail_uri.setter # type: ignore
def cached_thumbnail_uri(self, value):
self._cached_thumbnail_uri = value
diff --git a/gnomemusic/coredisc.py b/gnomemusic/coredisc.py
index 4307f0ed..697089a6 100644
--- a/gnomemusic/coredisc.py
+++ b/gnomemusic/coredisc.py
@@ -113,7 +113,7 @@ class CoreDisc(GObject.GObject):
def selected(self):
return self._selected
- @selected.setter
+ @selected.setter # type: ignore
def selected(self, value):
self._selected = value
diff --git a/gnomemusic/coresong.py b/gnomemusic/coresong.py
index eaa67fc5..ddd0e9fd 100644
--- a/gnomemusic/coresong.py
+++ b/gnomemusic/coresong.py
@@ -86,7 +86,7 @@ class CoreSong(GObject.GObject):
def favorite(self):
return self._favorite
- @favorite.setter
+ @favorite.setter # type: ignore
def favorite(self, favorite):
if not self._is_tracker:
return
@@ -105,7 +105,7 @@ class CoreSong(GObject.GObject):
def selected(self):
return self._selected
- @selected.setter
+ @selected.setter # type: ignore
def selected(self, value):
if not self._is_tracker:
return
diff --git a/gnomemusic/grilowrappers/grltrackerplaylists.py b/gnomemusic/grilowrappers/grltrackerplaylists.py
index b59eefae..dbd8766f 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -348,7 +348,7 @@ class Playlist(GObject.GObject):
return self._model
- @model.setter
+ @model.setter # type: ignore
def model(self, value):
self._model = value
@@ -445,7 +445,7 @@ class Playlist(GObject.GObject):
"""
return self._title
- @title.setter
+ @title.setter # type: ignore
def title(self, new_name):
"""Rename a playlist
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 0cde75e4..ba2d1ad3 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -108,7 +108,7 @@ class GrlTrackerWrapper(GObject.GObject):
def source(self):
return self._source
- @source.setter
+ @source.setter # type: ignore
def source(self, new_source):
"""Set a new grilo tracker source
diff --git a/gnomemusic/gstplayer.py b/gnomemusic/gstplayer.py
index 978a0e8d..cb248fd8 100644
--- a/gnomemusic/gstplayer.py
+++ b/gnomemusic/gstplayer.py
@@ -215,7 +215,7 @@ class GstPlayer(GObject.GObject):
"""
return self._state
- @state.setter
+ @state.setter # type: ignore
def state(self, state):
"""Set state of the player
@@ -239,7 +239,7 @@ class GstPlayer(GObject.GObject):
"""
return self._player.props.current_uri
- @url.setter
+ @url.setter # type: ignore
def url(self, url_):
"""url to load next
@@ -274,7 +274,7 @@ class GstPlayer(GObject.GObject):
# Setter provided to trigger a property signal.
# For internal use only.
- @duration.setter
+ @duration.setter # type: ignore
def duration(self, duration):
"""Set duration of current media (internal)
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index a550b56b..84ddb920 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -559,7 +559,7 @@ class Player(GObject.GObject):
def repeat_mode(self):
return self._repeat
- @repeat_mode.setter
+ @repeat_mode.setter # type: ignore
def repeat_mode(self, mode):
if mode == self._repeat:
return
diff --git a/gnomemusic/scrobbler.py b/gnomemusic/scrobbler.py
index 98bf0ba1..a385d7e2 100644
--- a/gnomemusic/scrobbler.py
+++ b/gnomemusic/scrobbler.py
@@ -270,7 +270,7 @@ class LastFmScrobbler(GObject.GObject):
"""
return self._account_state
- @account_state.setter
+ @account_state.setter # type: ignore
def account_state(self, value):
"""Set the Last.fm account state
@@ -294,7 +294,7 @@ class LastFmScrobbler(GObject.GObject):
return (self.props.account_state == GoaLastFM.State.ENABLED
and self._report is True)
- @can_scrobble.setter
+ @can_scrobble.setter # type: ignore
def can_scrobble(self, value):
"""Set the can_scrobble status
@@ -320,7 +320,7 @@ class LastFmScrobbler(GObject.GObject):
"""Bool indicating current scrobble status"""
return self._scrobbled
- @scrobbled.setter
+ @scrobbled.setter # type: ignore
def scrobbled(self, scrobbled):
self._scrobbled = scrobbled
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index e7a7c1c2..7666b6ce 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -175,7 +175,7 @@ class ArtistsView(Gtk.Box):
"""
return self._selection_mode
- @selection_mode.setter
+ @selection_mode.setter # type: ignore
def selection_mode(self, value):
"""selection-mode setter
diff --git a/gnomemusic/views/emptyview.py b/gnomemusic/views/emptyview.py
index b7efcd2a..cde31af1 100644
--- a/gnomemusic/views/emptyview.py
+++ b/gnomemusic/views/emptyview.py
@@ -89,7 +89,7 @@ class EmptyView(Gtk.Stack):
"""
return self._state
- @state.setter
+ @state.setter # type: ignore
def state(self, value):
"""Set the state of the empty view
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 1b727e09..9660a119 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -471,7 +471,7 @@ class SearchView(Gtk.Stack):
"""
return self._search_mode_active
- @search_mode_active.setter
+ @search_mode_active.setter # type: ignore
def search_mode_active(self, value):
"""Set search mode status.
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index 267e39cb..984487a9 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -114,7 +114,7 @@ class SongsView(Gtk.ScrolledWindow):
"""
return self._selection_mode
- @selection_mode.setter
+ @selection_mode.setter # type: ignore
def selection_mode(self, value):
"""selection-mode setter
diff --git a/gnomemusic/widgets/artistartstack.py b/gnomemusic/widgets/artistartstack.py
index 5cf3bb9a..fc68fc52 100644
--- a/gnomemusic/widgets/artistartstack.py
+++ b/gnomemusic/widgets/artistartstack.py
@@ -82,7 +82,7 @@ class ArtistArtStack(Gtk.Stack):
"""
return self._size
- @size.setter
+ @size.setter # type: ignore
def size(self, value):
"""Set the cover size
@@ -98,7 +98,7 @@ class ArtistArtStack(Gtk.Stack):
def coreartist(self):
return self._coreartist
- @coreartist.setter
+ @coreartist.setter # type: ignore
def coreartist(self, coreartist):
self._coreartist = coreartist
diff --git a/gnomemusic/widgets/coverstack.py b/gnomemusic/widgets/coverstack.py
index 1e97e489..89c84405 100644
--- a/gnomemusic/widgets/coverstack.py
+++ b/gnomemusic/widgets/coverstack.py
@@ -80,7 +80,7 @@ class CoverStack(Gtk.Stack):
"""
return self._size
- @size.setter
+ @size.setter # type: ignore
def size(self, value):
"""Set the cover size
diff --git a/gnomemusic/widgets/headerbar.py b/gnomemusic/widgets/headerbar.py
index 909974a2..2ed6bcfc 100644
--- a/gnomemusic/widgets/headerbar.py
+++ b/gnomemusic/widgets/headerbar.py
@@ -55,7 +55,7 @@ class SelectionBarMenuButton(Gtk.MenuButton):
"""
return self._selected_items_count
- @selected_items_count.setter
+ @selected_items_count.setter # type: ignore
def selected_items_count(self, value):
"""Set the number of items selected
@@ -153,7 +153,7 @@ class HeaderBar(Gtk.HeaderBar):
"""
return self._selection_mode
- @selection_mode.setter
+ @selection_mode.setter # type: ignore
def selection_mode(self, mode):
"""Set the selection mode
@@ -178,7 +178,7 @@ class HeaderBar(Gtk.HeaderBar):
"""
return self._state
- @state.setter
+ @state.setter # type: ignore
def state(self, value):
"""Set state of the of widget
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index e060f02d..ee551a68 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -84,7 +84,7 @@ class PlayerToolbar(Gtk.ActionBar):
"""
return self._player
- @player.setter
+ @player.setter # type: ignore
def player(self, player):
"""Set the GstPlayer object used
diff --git a/gnomemusic/widgets/playlistcontrols.py b/gnomemusic/widgets/playlistcontrols.py
index c406c18f..def8b944 100644
--- a/gnomemusic/widgets/playlistcontrols.py
+++ b/gnomemusic/widgets/playlistcontrols.py
@@ -70,7 +70,7 @@ class PlaylistControls(Gtk.Grid):
"""
return self._application
- @application.setter
+ @application.setter # type: ignore
def application(self, application):
"""Set the Application object used
@@ -157,7 +157,7 @@ class PlaylistControls(Gtk.Grid):
"""
return self._playlist
- @playlist.setter
+ @playlist.setter # type: ignore
def playlist(self, new_playlist):
"""Playlist property setter.
diff --git a/gnomemusic/widgets/searchheaderbar.py b/gnomemusic/widgets/searchheaderbar.py
index d67e8f93..24edc18c 100644
--- a/gnomemusic/widgets/searchheaderbar.py
+++ b/gnomemusic/widgets/searchheaderbar.py
@@ -108,7 +108,7 @@ class SearchHeaderBar(Gtk.HeaderBar):
"""
return self._selection_mode
- @selection_mode.setter
+ @selection_mode.setter # type: ignore
def selection_mode(self, mode):
"""Set the selection mode
@@ -133,7 +133,7 @@ class SearchHeaderBar(Gtk.HeaderBar):
"""
return self._state
- @state.setter
+ @state.setter # type: ignore
def state(self, value):
"""Set state of the of widget
diff --git a/gnomemusic/widgets/smoothscale.py b/gnomemusic/widgets/smoothscale.py
index 31bd85cd..d1f6d3f9 100644
--- a/gnomemusic/widgets/smoothscale.py
+++ b/gnomemusic/widgets/smoothscale.py
@@ -64,7 +64,7 @@ class SmoothScale(Gtk.Scale):
"""
return self._player
- @player.setter
+ @player.setter # type: ignore
def player(self, player):
"""Set the Player object used
diff --git a/gnomemusic/widgets/songwidget.py b/gnomemusic/widgets/songwidget.py
index 8846e876..1c494e07 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -234,7 +234,7 @@ class SongWidget(Gtk.EventBox):
"""
return self._selection_mode
- @selection_mode.setter
+ @selection_mode.setter # type: ignore
def selection_mode(self, value):
"""Set the selection mode
@@ -262,7 +262,7 @@ class SongWidget(Gtk.EventBox):
"""
return self._state
- @state.setter
+ @state.setter # type: ignore
def state(self, value):
"""Set state of the of widget
@@ -308,7 +308,7 @@ class SongWidget(Gtk.EventBox):
"""
return self._number_label.props.label
- @song_number.setter
+ @song_number.setter # type: ignore
def song_number(self, new_nr):
"""Set song number label from an integer
diff --git a/gnomemusic/widgets/starhandlerwidget.py b/gnomemusic/widgets/starhandlerwidget.py
index 2657237f..08df4e88 100644
--- a/gnomemusic/widgets/starhandlerwidget.py
+++ b/gnomemusic/widgets/starhandlerwidget.py
@@ -81,7 +81,7 @@ class CellRendererStar(Gtk.CellRendererPixbuf):
def show_star(self):
return self._show_star
- @show_star.setter
+ @show_star.setter # type: ignore
def show_star(self, value):
"""Set the show-star value
diff --git a/gnomemusic/widgets/starimage.py b/gnomemusic/widgets/starimage.py
index 032bf6e3..1d84ecd3 100644
--- a/gnomemusic/widgets/starimage.py
+++ b/gnomemusic/widgets/starimage.py
@@ -47,7 +47,7 @@ class StarImage(Gtk.Image):
"""
return self._favorite
- @favorite.setter
+ @favorite.setter # type: ignore
def favorite(self, value):
"""Set favorite
@@ -66,7 +66,7 @@ class StarImage(Gtk.Image):
def hover(self):
return self._hover
- @hover.setter
+ @hover.setter # type: ignore
def hover(self, value):
if value:
self.set_state_flags(Gtk.StateFlags.PRELIGHT, False)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]