Skip to content

Commit b8c1cf3

Browse files
committed
More linter and types
1 parent 6b98df9 commit b8c1cf3

File tree

7 files changed

+32
-28
lines changed

7 files changed

+32
-28
lines changed

scc/controller.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
if TYPE_CHECKING:
88
from scc.controller import HapticData
9-
9+
from scc.mapper import Mapper
1010
import logging
1111
import time
1212

@@ -15,17 +15,16 @@
1515
next_id = 1 # Used with fallback controller id generator
1616

1717
class Controller(object):
18-
"""
19-
Base class for all controller drivers. Implementations are in
20-
scc.drivers package.
18+
"""Base class for all controller drivers. Implementations are in scc.drivers package.
2119
2220
Derived class should implement every method from here.
2321
"""
22+
2423
flags = 0
2524

26-
def __init__(self):
25+
def __init__(self) -> None:
2726
global next_id
28-
self.mapper = None
27+
self.mapper: Mapper | None = None
2928
self._id = next_id
3029
next_id += 1
3130
self.lastTime = time.time()
@@ -66,7 +65,7 @@ def get_gui_config_file(self) -> None:
6665
return None
6766

6867

69-
def set_mapper(self, mapper):
68+
def set_mapper(self, mapper: Mapper):
7069
""" Sets mapper for controller """
7170
self.mapper = mapper
7271

scc/drivers/ds4drv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def _load_hid_descriptor(self, config, max_size, vid, pid, test_mode):
148148
self._packet_size = 64
149149

150150

151-
def input(self, endpoint, data):
151+
def input(self, endpoint: bytearray, data: int) -> None:
152152
# Special override for CPAD touch button
153153
if _lib.decode(ctypes.byref(self._decoder), data):
154154
if self.mapper:

scc/drivers/hiddrv.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
import os
99
import sys
1010
from enum import IntEnum
11+
from typing import TYPE_CHECKING
12+
13+
if TYPE_CHECKING:
14+
from scc.sccdaemon import SCCDaemon
1115

1216
from scc.constants import STICK_PAD_MAX, STICK_PAD_MIN, ControllerFlags, SCButtons
1317
from scc.controller import Controller
@@ -202,7 +206,7 @@ class HIDController(USBDevice, Controller):
202206
| ControllerFlags.HAS_DPAD
203207
| ControllerFlags.NO_GRIPS )
204208

205-
def __init__(self, device, daemon, handle, config_file, config, test_mode=False):
209+
def __init__(self, device, daemon: "SCCDaemon", handle, config_file, config, test_mode=False):
206210
USBDevice.__init__(self, device, handle)
207211
self._ready = False
208212
self.daemon = daemon

scc/drivers/usb.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ def __init__(self, device, handle):
3535

3636

3737
def set_input_interrupt(self, endpoint, size, callback):
38-
"""
39-
Helper method for setting up input transfer.
38+
"""Set up input transfer.
4039
4140
callback(endpoint, data) is called repeadedly with every packed received.
4241
"""
@@ -66,7 +65,7 @@ def callback_wrapper(transfer):
6665

6766

6867
def send_control(self, index, data):
69-
""" Schedules writing control to device """
68+
"""Schedules writing control to device."""
7069
zeros = b'\x00' * (64 - len(data))
7170

7271
self._cmsg.insert(0, (

scc/lib/hidparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def enum_or_reserved(enum, value):
101101
_HIDIOCGRDESCSIZE = ioctl_opt.IOR(ord('H'), 0x01, ctypes.c_int)
102102
_HIDIOCGRDESC = ioctl_opt.IOR(ord('H'), 0x02, _hidraw_report_descriptor)
103103
_HIDIOCGRAWINFO = ioctl_opt.IOR(ord('H'), 0x03, _hidraw_devinfo)
104-
#_HIDIOCGFEATURE = lambda len : ioctl_opt.IORW(ord('H'), 0x07, len)
104+
#_HIDIOCGFEATURE = lambda len : ioctl_opt.IOWR(ord('H'), 0x07, len)
105105
_HIDIOCGFEATURE = lambda len: ioctl_opt.IOC(
106106
ioctl_opt.IOC_WRITE|ioctl_opt.IOC_READ, ord('H'), 0x07, len)
107107

scc/modifiers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _mod_init(self):
6060

6161

6262
def _mod_to_string(self, params, multiline, pad):
63-
""" Adds action at end of params list and generates string """
63+
"""Add action at end of params list and generate a string."""
6464
if multiline:
6565
childstr = self.action.to_string(True, pad + 2)
6666
if len(params) > 0:

scc/x11/scc-osd-daemon.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
#!/usr/bin/env python3
22

3-
"""
4-
SC-Controller - OSD Daemon
3+
"""SC-Controller - OSD Daemon.
54
65
Controls stuff displayed as OSD.
76
"""
8-
from scc.tools import set_logging_level
9-
7+
import logging
108
import os
119
import sys
12-
import logging
1310
import time
1411
import traceback
12+
1513
import gi
14+
15+
from scc.tools import set_logging_level
16+
1617
gi.require_version('Gtk', '3.0')
1718
gi.require_version('Rsvg', '2.0')
1819
gi.require_version('GdkX11', '3.0')
19-
from gi.repository import Gtk, Gdk, GdkX11, GLib
20+
from gi.repository import Gdk, GdkX11, GLib, Gtk
21+
22+
from scc.config import Config
2023
from scc.gui.daemon_manager import DaemonManager
24+
from scc.osd import OSDWindow
25+
from scc.osd.area import Area
26+
from scc.osd.dialog import Dialog
2127
from scc.osd.gesture_display import GestureDisplay
22-
from scc.osd.radial_menu import RadialMenu
23-
from scc.osd.hmenu import HorizontalMenu
24-
from scc.osd.quick_menu import QuickMenu
2528
from scc.osd.grid_menu import GridMenu
29+
from scc.osd.hmenu import HorizontalMenu
2630
from scc.osd.keyboard import Keyboard
27-
from scc.osd.message import Message
28-
from scc.osd.dialog import Dialog
29-
from scc.osd import OSDWindow
3031
from scc.osd.menu import Menu
31-
from scc.osd.area import Area
32+
from scc.osd.message import Message
33+
from scc.osd.quick_menu import QuickMenu
34+
from scc.osd.radial_menu import RadialMenu
3235
from scc.special_actions import OSDAction
3336
from scc.tools import shsplit
34-
from scc.config import Config
3537

3638
log = logging.getLogger("osd.daemon")
3739

0 commit comments

Comments
 (0)