Skip to content

Commit c1d5550

Browse files
authored
Merge pull request slgobinath#696 from deltragon/typing-mypy
CI: Type checking: mypy
2 parents db81e72 + d139a50 commit c1d5550

File tree

5 files changed

+77
-6
lines changed

5 files changed

+77
-6
lines changed

.github/workflows/mypy.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Workflow to run mypy
2+
# Adapted from the CPython mypy action
3+
name: mypy
4+
5+
on: [push, pull_request]
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
UV_SYSTEM_PYTHON: 1
12+
PIP_DISABLE_PIP_VERSION_CHECK: 1
13+
FORCE_COLOR: 1
14+
TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817
15+
16+
jobs:
17+
mypy:
18+
name: mypy
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
with:
23+
persist-credentials: false
24+
- uses: astral-sh/setup-uv@22695119d769bdb6f7032ad67b9bca0ef8c4a174 # v5.4.0
25+
with:
26+
enable-cache: true
27+
cache-dependency-glob: ''
28+
cache-suffix: '3.13'
29+
- name: Setup Python
30+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
31+
with:
32+
python-version: '3.13'
33+
- run: sudo apt-get install -y libwayland-dev libcairo2-dev libgirepository-2.0-dev
34+
- run: uv pip install -r pyproject.toml
35+
- run: uv pip install --group types
36+
- run: mypy safeeyes

pyproject.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,35 @@ build-backend = "setuptools.build_meta"
4646

4747
[tool.setuptools.packages.find]
4848
include=["safeeyes*"]
49+
50+
[dependency-groups]
51+
dev = [
52+
{include-group = "lint"},
53+
{include-group = "scripts"},
54+
{include-group = "types"}
55+
]
56+
lint = [
57+
"ruff==0.11.2"
58+
]
59+
scripts = [
60+
"polib==1.2.0"
61+
]
62+
types = [
63+
"mypy==1.15.0",
64+
"PyGObject-stubs==2.13.0",
65+
"types-croniter==5.0.1.20250322",
66+
"types-psutil==7.0.0.20250218",
67+
"types-python-xlib==0.33.0.20240407"
68+
]
69+
70+
[tool.mypy]
71+
# catch typos in configuration file
72+
warn_unused_configs = true
73+
disallow_any_unimported = true
74+
#check_untyped_defs = true
75+
warn_unused_ignores = true
76+
warn_unreachable = true
77+
enable_error_code = [
78+
"ignore-without-code",
79+
"possibly-undefined"
80+
]

safeeyes/plugins/donotdisturb/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
from safeeyes import utility
3131

3232
context = None
33-
skip_break_window_classes = []
34-
take_break_window_classes = []
33+
skip_break_window_classes: list[str] = []
34+
take_break_window_classes: list[str] = []
3535
unfullscreen_allowed = True
3636
dnd_while_on_battery = False
3737

safeeyes/plugins/trayicon/plugin.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from safeeyes import utility
2727
import threading
2828
import time
29+
import typing
2930

3031
"""
3132
Safe Eyes tray icon plugin
@@ -186,8 +187,10 @@ class DBusMenuService(DBusService):
186187

187188
revision = 0
188189

189-
items = []
190-
idToItems = {}
190+
# TODO: replace dict here with more exact typing for item
191+
items: list[dict] = []
192+
# TODO: replace dict here with more exact typing for item
193+
idToItems: dict[str, dict] = {}
191194

192195
def __init__(self, session_bus, context, items):
193196
super().__init__(
@@ -366,7 +369,7 @@ class StatusNotifierItemService(DBusService):
366369
Status = "Active"
367370
IconName = "io.github.slgobinath.SafeEyes-enabled"
368371
IconThemePath = ""
369-
ToolTip = ("", [], "Safe Eyes", "")
372+
ToolTip: tuple[str, list[typing.Any], str, str] = ("", [], "Safe Eyes", "")
370373
XAyatanaLabel = ""
371374
ItemIsMenu = True
372375
Menu = None

safeeyes/ui/break_screen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from safeeyes import utility
2626
import Xlib
2727
from Xlib.display import Display
28-
from Xlib.display import X
28+
from Xlib import X
2929

3030
gi.require_version("Gtk", "4.0")
3131
from gi.repository import Gdk

0 commit comments

Comments
 (0)