From bbdaec1af466d13fef42ea3e375702a9e10552be Mon Sep 17 00:00:00 2001 From: pomdtr Date: Wed, 20 Dec 2023 14:48:07 +0100 Subject: [PATCH] add black to the list of dependencies, format package --- pkg/python/pyproject.toml | 7 +++++-- pkg/python/sunbeam/__init__.py | 2 +- pkg/python/sunbeam/manifest.py | 10 +++++++++- pkg/python/sunbeam/page.py | 19 ++++++++++++++++++- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/pkg/python/pyproject.toml b/pkg/python/pyproject.toml index 8cc59eaa..e820792f 100644 --- a/pkg/python/pyproject.toml +++ b/pkg/python/pyproject.toml @@ -4,11 +4,14 @@ build-backend = "flit_core.buildapi" [project] name = "sunbeam" -authors = [{name = "Achille Lacoin", email = "achille.lacoin@gmail.com"}] +authors = [{ name = "Achille Lacoin", email = "achille.lacoin@gmail.com" }] readme = "README.md" -license = {file = "LICENSE"} +license = { file = "LICENSE" } classifiers = ["License :: OSI Approved :: MIT License"] dynamic = ["version", "description"] +[project.optional-dependencies] +dev = ["black"] + [project.urls] Home = "https://sunbeam.sh" diff --git a/pkg/python/sunbeam/__init__.py b/pkg/python/sunbeam/__init__.py index 743e4bcf..15a888d4 100644 --- a/pkg/python/sunbeam/__init__.py +++ b/pkg/python/sunbeam/__init__.py @@ -3,4 +3,4 @@ from .manifest import * from .page import * -__version__ = '0.2.0' +__version__ = "0.2.0" diff --git a/pkg/python/sunbeam/manifest.py b/pkg/python/sunbeam/manifest.py index 27e06751..6ab8b974 100644 --- a/pkg/python/sunbeam/manifest.py +++ b/pkg/python/sunbeam/manifest.py @@ -1,23 +1,29 @@ from typing import TypedDict, NotRequired, Literal + class TextInput(TypedDict): default: NotRequired[str] placeholder: NotRequired[str] + class TextAreaInput(TypedDict): default: NotRequired[str] placeholder: NotRequired[str] + class CheckboxInput(TypedDict): default: NotRequired[bool] + class PasswordInput(TypedDict): placeholder: NotRequired[str] + class NumberInput(TypedDict): default: NotRequired[int] placeholder: NotRequired[str] + class Input(TypedDict): label: str type: str @@ -29,15 +35,17 @@ class Input(TypedDict): password: NotRequired[PasswordInput] number: NotRequired[NumberInput] + CommandMode = Literal["silent", "tty", "filter", "search", "detail"] + class Command: name: str title: str params: list[Input] + class Manifest(TypedDict): title: str description: str preferences: NotRequired[list[Input]] - diff --git a/pkg/python/sunbeam/page.py b/pkg/python/sunbeam/page.py index f9547bd6..add9426b 100644 --- a/pkg/python/sunbeam/page.py +++ b/pkg/python/sunbeam/page.py @@ -1,24 +1,36 @@ from typing import TypedDict, NotRequired, Literal + class Param(TypedDict): default: NotRequired[str | int | bool] + class RunAction(TypedDict): command: str params: dict[str, str | int | bool | Param] + class ReloadAction(TypedDict): params: dict[str, str | int | bool | Param] + class OpenAction(TypedDict): url: NotRequired[str] path: NotRequired[str] + class CopyAction(TypedDict): text: str exit: NotRequired[bool] -ActionType = Literal["copy", "open", "run", "reload", "exit"] + +class EditAction(TypedDict): + path: str + reload: NotRequired[bool] + + +ActionType = Literal["copy", "open", "run", "reload", "exit", "edit", "exit"] + class Action(TypedDict): title: str @@ -27,11 +39,14 @@ class Action(TypedDict): copy: NotRequired[CopyAction] open: NotRequired[OpenAction] run: NotRequired[RunAction] + edit: NotRequired[EditAction] + class ListItemDetail(TypedDict): markdown: NotRequired[str] text: NotRequired[str] + class ListItem(TypedDict): title: str id: NotRequired[str] @@ -40,12 +55,14 @@ class ListItem(TypedDict): accessories: NotRequired[list[str]] actions: list[Action] + class List(TypedDict): items: NotRequired[list[ListItem]] showDetail: NotRequired[bool] actions: NotRequired[list[Action]] emptyText: NotRequired[str] + class Detail(TypedDict): markdown: NotRequired[str] text: NotRequired[str]