Integrated mypy; added coc config; started fixing a few mypy errors

This commit is contained in:
Sumner Evans
2019-11-21 22:38:00 -07:00
parent a4625b5a64
commit fa3db6df66
7 changed files with 26 additions and 9 deletions

View File

@@ -19,7 +19,8 @@ lint:
- pip3 install -e . - pip3 install -e .
script: script:
- python3 setup.py check -mrs - python3 setup.py check -mrs
- pycodestyle - flake8
- mypy sublime
test: test:
stage: test stage: test

7
.vim/coc-settings.json Normal file
View File

@@ -0,0 +1,7 @@
{
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"python.linting.mypyEnabled": true,
"python.formatting.provider": "yapf"
}

View File

@@ -1,5 +1,6 @@
pytest pytest
pytest-cov pytest-cov
docutils docutils
pycodestyle flake8
mypy
lxml lxml

View File

@@ -1,6 +1,12 @@
[pycodestyle] [flake8]
ignore = E402, W503 ignore = E402, W503
[mypy-gi]
ignore_missing_imports = True
[mypy-gi.repository]
ignore_missing_imports = True
[yapf] [yapf]
based_on_style = pep8 based_on_style = pep8
split_before_bitwise_operator = true split_before_bitwise_operator = true

View File

@@ -1,6 +1,6 @@
import os import os
from typing import List from typing import List, Optional
class ServerConfiguration: class ServerConfiguration:
@@ -79,7 +79,7 @@ class AppConfiguration:
return os.path.join(default_cache_location, 'sublime-music') return os.path.join(default_cache_location, 'sublime-music')
@property @property
def server(self) -> ServerConfiguration: def server(self) -> Optional[ServerConfiguration]:
return ( return (
None if self.current_server < 0 or len(self.servers) < 1 else None if self.current_server < 0 or len(self.servers) < 1 else
self.servers[self.current_server]) self.servers[self.current_server])

View File

@@ -1,5 +1,5 @@
import gi import gi
from typing import Optional, Union from typing import Union
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject, GLib, Gio, Pango from gi.repository import Gtk, GObject, GLib, Gio, Pango
@@ -161,7 +161,7 @@ class AlbumsPanel(Gtk.Box):
show_if('byYear', self.to_year_label, self.to_year_entry) show_if('byYear', self.to_year_label, self.to_year_entry)
self.grid.update( self.grid.update(
state=state, state,
force=force, force=force,
selected_id=state.selected_album_id, selected_id=state.selected_album_id,
) )
@@ -380,7 +380,7 @@ class AlbumsGrid(Gtk.Overlay):
def update( def update(
self, self,
state: ApplicationState = None, state: ApplicationState,
force: bool = False, force: bool = False,
selected_id: str = None, selected_id: str = None,
): ):

View File

@@ -4,6 +4,8 @@ import gi
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
from gi.repository import Gtk from gi.repository import Gtk
NumericFieldDescription = Tuple[str, str, Tuple[int, int, int], int]
class EditFormDialog(Gtk.Dialog): class EditFormDialog(Gtk.Dialog):
entity_name: str entity_name: str
@@ -11,7 +13,7 @@ class EditFormDialog(Gtk.Dialog):
initial_size: Tuple[int, int] initial_size: Tuple[int, int]
text_fields: List[Tuple[str, str, bool]] = [] text_fields: List[Tuple[str, str, bool]] = []
boolean_fields: List[Tuple[str, str]] = [] boolean_fields: List[Tuple[str, str]] = []
numeric_fields: List[Tuple[str, str]] = [] numeric_fields: List[NumericFieldDescription] = []
extra_buttons: List[Gtk.Button] = [] extra_buttons: List[Gtk.Button] = []
def get_object_name(self, obj): def get_object_name(self, obj):