Skip to content

Commit

Permalink
Support files for Python typing
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Apr 22, 2024
1 parent f2f96fd commit fcc9d5b
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ install
.venv
__pycache__
*.pyc
*.egg-info

# IDEs / editors
.idea
Expand Down
31 changes: 31 additions & 0 deletions python-aux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Python Development Support Files

This directory contains support files for developing Python demos:

- `requirements.txt`:
Requirements for development. Contains dependency for `ruff` (linter & formatter), `mypy` (type checker)
and `workbench-typestubs` (typestubs for the `workbench` module). All of these are also installed
in the `re.sonny.Workbench.Devel` Flatpak (TODO: not true yet, see below.)
- `mypy.ini`:
Rules for `mypy` used for all demos.
- `workbench-typestubs`:
Python package containing typestubs for the `workbench` package which is available to demos and
implements the Workbench API.

## Run type checks.

```sh
cd python-aux
pip3 install -r requirements.txt
cd ..
# Check single file:
mypy --config-file python-aux/mypy.ini src/Welcome/main.py
# Check all:
mypy --config-file python-aux/mypy.ini src
```

## TODO

TODO: All requirements should be in the Devel Flatpak, but unsure how the
typestub itself could be added there...? We might need to put that in an extra repo and add it
as a module to the Devel Flatpak. Ruff is already in there.
5 changes: 5 additions & 0 deletions python-aux/mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[mypy]
warn_unused_configs = True
explicit_package_bases = True
namespace_packages = True
check_untyped_defs = True
4 changes: 4 additions & 0 deletions python-aux/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
./workbench-typestubs
ruff>=0.3.0
pygobject-stubs>=2.11.0 --config-settings=config=Gtk4,Gdk4,GtkSource5
mypy>=1.9.0
2 changes: 2 additions & 0 deletions python-aux/workbench-typestubs/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include workbench/py.typed
recursive-include workbench *.pyi
7 changes: 7 additions & 0 deletions python-aux/workbench-typestubs/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = ["setuptools"] # REQUIRED if [build-system] table is used
build-backend = "setuptools.build_meta" # If not defined, then legacy behavior can happen.

[project]
name = "workbench-typestubs"
version = "46.0.0"
7 changes: 7 additions & 0 deletions python-aux/workbench-typestubs/workbench/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from gi.repository import Gtk, Gio

window: Gtk.Window
builder: Gtk.Builder

def resolve(self, path: str) -> Gio.File:
...
Empty file.

0 comments on commit fcc9d5b

Please sign in to comment.