Skip to content

Commit fcc9d5b

Browse files
committed
Support files for Python typing
1 parent f2f96fd commit fcc9d5b

File tree

8 files changed

+57
-0
lines changed

8 files changed

+57
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ install
1414
.venv
1515
__pycache__
1616
*.pyc
17+
*.egg-info
1718

1819
# IDEs / editors
1920
.idea

python-aux/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Python Development Support Files
2+
3+
This directory contains support files for developing Python demos:
4+
5+
- `requirements.txt`:
6+
Requirements for development. Contains dependency for `ruff` (linter & formatter), `mypy` (type checker)
7+
and `workbench-typestubs` (typestubs for the `workbench` module). All of these are also installed
8+
in the `re.sonny.Workbench.Devel` Flatpak (TODO: not true yet, see below.)
9+
- `mypy.ini`:
10+
Rules for `mypy` used for all demos.
11+
- `workbench-typestubs`:
12+
Python package containing typestubs for the `workbench` package which is available to demos and
13+
implements the Workbench API.
14+
15+
## Run type checks.
16+
17+
```sh
18+
cd python-aux
19+
pip3 install -r requirements.txt
20+
cd ..
21+
# Check single file:
22+
mypy --config-file python-aux/mypy.ini src/Welcome/main.py
23+
# Check all:
24+
mypy --config-file python-aux/mypy.ini src
25+
```
26+
27+
## TODO
28+
29+
TODO: All requirements should be in the Devel Flatpak, but unsure how the
30+
typestub itself could be added there...? We might need to put that in an extra repo and add it
31+
as a module to the Devel Flatpak. Ruff is already in there.

python-aux/mypy.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[mypy]
2+
warn_unused_configs = True
3+
explicit_package_bases = True
4+
namespace_packages = True
5+
check_untyped_defs = True

python-aux/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
./workbench-typestubs
2+
ruff>=0.3.0
3+
pygobject-stubs>=2.11.0 --config-settings=config=Gtk4,Gdk4,GtkSource5
4+
mypy>=1.9.0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include workbench/py.typed
2+
recursive-include workbench *.pyi
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build-system]
2+
requires = ["setuptools"] # REQUIRED if [build-system] table is used
3+
build-backend = "setuptools.build_meta" # If not defined, then legacy behavior can happen.
4+
5+
[project]
6+
name = "workbench-typestubs"
7+
version = "46.0.0"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from gi.repository import Gtk, Gio
2+
3+
window: Gtk.Window
4+
builder: Gtk.Builder
5+
6+
def resolve(self, path: str) -> Gio.File:
7+
...

python-aux/workbench-typestubs/workbench/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)