From 3b0c3a8be83c8b9d0e0f40da8cb56d1fb1944183 Mon Sep 17 00:00:00 2001 From: Kieran W <41634689+FredHappyface@users.noreply.github.com> Date: Tue, 18 Feb 2025 21:18:18 +0000 Subject: [PATCH] ruff fixes --- cli2gui/application/application.py | 4 +- cli2gui/application/application2args.py | 22 +++--- cli2gui/decorators.py | 2 +- cli2gui/gui/__init__.py | 2 + cli2gui/gui/abstract_gui.py | 12 ++- cli2gui/gui/dearpygui_wrapper.py | 9 ++- cli2gui/gui/helpers.py | 3 + cli2gui/gui/pysimplegui_wrapper.py | 27 +++---- cli2gui/{types.py => models.py} | 16 +--- cli2gui/tojson/__init__.py | 2 + cli2gui/tojson/argparse2json.py | 9 ++- cli2gui/tojson/click2json.py | 2 +- cli2gui/tojson/docopt2json.py | 10 +-- cli2gui/tojson/getopt2json.py | 2 +- cli2gui/tojson/optparse2json.py | 2 +- documentation/reference/README.md | 2 +- .../cli2gui/application/application.md | 2 +- documentation/reference/cli2gui/decorators.md | 4 +- .../reference/cli2gui/gui/abstract_gui.md | 9 ++- .../cli2gui/gui/dearpygui_wrapper.md | 24 +++--- .../reference/cli2gui/gui/helpers.md | 12 +-- .../cli2gui/gui/pysimplegui_wrapper.md | 75 +++++++++---------- documentation/reference/cli2gui/index.md | 4 +- .../reference/cli2gui/{types.md => models.md} | 37 +++------ .../reference/cli2gui/tojson/argparse2json.md | 34 +++++---- .../reference/cli2gui/tojson/click2json.md | 10 +-- .../reference/cli2gui/tojson/docopt2json.md | 10 +-- .../reference/cli2gui/tojson/getopt2json.md | 14 ++-- .../reference/cli2gui/tojson/optparse2json.md | 12 +-- pyproject.toml | 3 +- tests/argparse/test_18.py | 6 +- tests/argparse/test_22.py | 6 +- 32 files changed, 197 insertions(+), 191 deletions(-) rename cli2gui/{types.py => models.py} (86%) rename documentation/reference/cli2gui/{types.md => models.md} (54%) diff --git a/cli2gui/application/application.py b/cli2gui/application/application.py index 21b2b58..46bdc87 100644 --- a/cli2gui/application/application.py +++ b/cli2gui/application/application.py @@ -6,14 +6,14 @@ import sys from typing import Any -from cli2gui import types +from cli2gui import models from cli2gui.application.application2args import argFormat from cli2gui.gui import helpers from cli2gui.gui.dearpygui_wrapper import DearPyGuiWrapper from cli2gui.gui.pysimplegui_wrapper import PySimpleGUIWrapper -def run(buildSpec: types.FullBuildSpec) -> Any: +def run(buildSpec: models.FullBuildSpec) -> Any: """Establish the main entry point. Args: diff --git a/cli2gui/application/application2args.py b/cli2gui/application/application2args.py index c3817fb..f9a4ccb 100644 --- a/cli2gui/application/application2args.py +++ b/cli2gui/application/application2args.py @@ -7,7 +7,7 @@ from pathlib import Path from typing import Any -from cli2gui.types import SEP, ParserType +from cli2gui.models import SEP, ParserType def processValue(key: str, value: str) -> tuple[str, Any]: @@ -44,8 +44,8 @@ def processValue(key: str, value: str) -> tuple[str, Any]: def argparseFormat(values: dict[str, Any]) -> argparse.Namespace: """Format args for argparse.""" args = {} - for key in values: - cleankey, value = processValue(key, values[key]) + for key, _value in values.items(): + cleankey, value = processValue(key, _value) args[cleankey] = value return argparse.Namespace(**args) @@ -53,15 +53,15 @@ def argparseFormat(values: dict[str, Any]) -> argparse.Namespace: def optparseFormat(values: dict[str, Any]) -> tuple[optparse.Values, list[str]]: """Format args for optparse.""" args = {} - for key in values: - cleankey, value = processValue(key, values[key]) + for key, _value in values.items(): + cleankey, value = processValue(key, _value) args[cleankey] = value return (optparse.Values(args), []) def getoptFormat(values: dict[str, Any]) -> tuple[list[Any], list[Any]]: """Format args for getopt.""" - return ([processValue(key, values[key]) for key in values if values[key]], []) + return ([processValue(key, _value) for key, _value in values.items() if _value], []) def docoptFormat(values: dict[str, Any]) -> dict[str, Any]: @@ -69,8 +69,8 @@ def docoptFormat(values: dict[str, Any]) -> dict[str, Any]: import docopt args = {} - for key in values: - cleankey, value = processValue(key, values[key]) + for key, _value in values.items(): + cleankey, value = processValue(key, _value) args[cleankey] = value return docopt.Dict(args) @@ -78,10 +78,10 @@ def docoptFormat(values: dict[str, Any]) -> dict[str, Any]: def clickFormat(values: dict[str, Any]) -> list[Any]: """Format args for click.""" args = [] - for key in values: - val = str(values[key]) + for key, _value in values.items(): + val = str(_value) if not callable(key) and len(val) > 0: - cleankey, value = processValue(key, values[key]) + cleankey, value = processValue(key, _value) args.extend([cleankey, value]) return args diff --git a/cli2gui/decorators.py b/cli2gui/decorators.py index e7af209..bc4e430 100644 --- a/cli2gui/decorators.py +++ b/cli2gui/decorators.py @@ -13,6 +13,7 @@ from typing import Any, Iterable from cli2gui.application import application +from cli2gui.models import BuildSpec, FullBuildSpec, GUIType, ParserType from cli2gui.tojson import ( argparse2json, click2json, @@ -20,7 +21,6 @@ getopt2json, optparse2json, ) -from cli2gui.types import BuildSpec, FullBuildSpec, GUIType, ParserType DO_COMMAND = "--cli2gui" DO_NOT_COMMAND = "--disable-cli2gui" diff --git a/cli2gui/gui/__init__.py b/cli2gui/gui/__init__.py index e69de29..d2d1015 100644 --- a/cli2gui/gui/__init__.py +++ b/cli2gui/gui/__init__.py @@ -0,0 +1,2 @@ +"""Package containing GUI classes and functionality, responsible for driving the various +GUI backends supported by cli2gui.""" diff --git a/cli2gui/gui/abstract_gui.py b/cli2gui/gui/abstract_gui.py index e069978..9f798de 100644 --- a/cli2gui/gui/abstract_gui.py +++ b/cli2gui/gui/abstract_gui.py @@ -1,8 +1,11 @@ +"""Abstract base class for GUI wrappers.""" + from __future__ import annotations from abc import ABC, abstractmethod +from typing import Any, Callable -from cli2gui import types +from cli2gui import models class AbstractGUI(ABC): @@ -10,11 +13,14 @@ class AbstractGUI(ABC): @abstractmethod def __init__(self) -> None: - pass + """Abstract base class for GUI wrappers.""" @abstractmethod def main( - self, buildSpec: types.FullBuildSpec, menu: list[str], quit_callback, run_callback + self, + buildSpec: models.FullBuildSpec, + quit_callback: Callable[[], None], + run_callback: Callable[[dict[str, Any]], None], ) -> None: """Abstract method for the main function.""" raise NotImplementedError diff --git a/cli2gui/gui/dearpygui_wrapper.py b/cli2gui/gui/dearpygui_wrapper.py index 792439d..93faa33 100644 --- a/cli2gui/gui/dearpygui_wrapper.py +++ b/cli2gui/gui/dearpygui_wrapper.py @@ -1,3 +1,5 @@ +"""Wrapper class for Dear PyGui.""" + from __future__ import annotations from pathlib import Path @@ -7,7 +9,7 @@ from cli2gui.gui import helpers from cli2gui.gui.abstract_gui import AbstractGUI -from cli2gui.types import SEP, FullBuildSpec, Group, Item, ItemType +from cli2gui.models import SEP, FullBuildSpec, Group, Item, ItemType THISDIR = Path(__file__).resolve().parent @@ -25,6 +27,11 @@ class DearPyGuiWrapper(AbstractGUI): """Wrapper class for Dear PyGui.""" def __init__(self, base24Theme: list[str]) -> None: + """Dearpygui wrapper class. + + :param list[str] base24Theme: list representing a base24 theme. Containing 24 elements + (of hex strings like "#e7e7e9") + """ self.base24Theme = base24Theme super().__init__() diff --git a/cli2gui/gui/helpers.py b/cli2gui/gui/helpers.py index a9d85f3..3babdd6 100644 --- a/cli2gui/gui/helpers.py +++ b/cli2gui/gui/helpers.py @@ -1,3 +1,6 @@ +"""Basic helper package containing commonly used functions, such as isDarkMode, +get_base24_theme etc.""" + from __future__ import annotations from pathlib import Path diff --git a/cli2gui/gui/pysimplegui_wrapper.py b/cli2gui/gui/pysimplegui_wrapper.py index aed8dbd..33ead2e 100644 --- a/cli2gui/gui/pysimplegui_wrapper.py +++ b/cli2gui/gui/pysimplegui_wrapper.py @@ -1,3 +1,5 @@ +"""Wrapper class for PySimpleGUI.""" + from __future__ import annotations import io @@ -8,15 +10,19 @@ from cli2gui.gui import helpers from cli2gui.gui.abstract_gui import AbstractGUI -from cli2gui.types import SEP, FullBuildSpec, Group, Item, ItemType - -# ruff: noqa: ANN401 +from cli2gui.models import SEP, FullBuildSpec, Group, Item, ItemType class PySimpleGUIWrapper(AbstractGUI): """Wrapper class for PySimpleGUI.""" def __init__(self, base24Theme: list[str], psg_lib: str) -> None: + """PySimpleGUI wrapper class. + + :param list[str] base24Theme: list representing a base24 theme. Containing 24 elements + (of hex strings like "#e7e7e9") + :param str psg_lib: string representing the pysimplegui lib to use + """ super().__init__() if psg_lib == "psg": @@ -138,14 +144,14 @@ def _fileBrowser( additional_properties: dict | None = None, ) -> list[Any]: """Return a fileBrowser button and field.""" - additional_properties = additional_properties or {} + prop = additional_properties or {} height = self.sizes["input_size"][1] width = self.sizes["input_size"][0] key = f"{key}{SEP}{_type}" if _type in [ItemType.FileWrite, ItemType.File]: - key += f";{additional_properties.get('file_mode')};{additional_properties.get('file_encoding')}" + key += f";{prop.get('file_mode')};{prop.get('file_encoding')}" browser = self.sg.FileBrowse( key="@@" + key, @@ -394,15 +400,10 @@ def createLayout( ) -> list[list[Any]]: """Create the pysimplegui layout from the build spec. - Args: - ---- - buildSpec (FullBuildSpec): build spec containing widget - self (self): class to build self - + :param FullBuildSpec buildSpec: build spec containing widget + :param str | list[str] menu: menu definition. containing menu keys - Returns: - ------- - list[list[Any]]: list of self (layout list) + :return list[list[Any]]: list of self (layout list) """ argConstruct = [] diff --git a/cli2gui/types.py b/cli2gui/models.py similarity index 86% rename from cli2gui/types.py rename to cli2gui/models.py index 477e3b0..4ab5bf2 100644 --- a/cli2gui/types.py +++ b/cli2gui/models.py @@ -98,13 +98,6 @@ class FullBuildSpec: class ParserType(str, Enum): """Supported parser types. - OPTPARSE = "optparse" - ARGPARSE = "argparse" - DEPHELL_ARGPARSE = "dephell_argparse" - DOCOPT = "docopt" - GETOPT = "getopt" - CLICK = "click" - CUSTOM = "input()" # this seems like a pretty poor pattern to use """ OPTPARSE = "optparse" @@ -120,13 +113,12 @@ class ParserType(str, Enum): class GUIType(str, Enum): """Supported gui types. - DEFAULT = "pysimplegui" - WEB = "pysimpleguiweb" - QT = "pysimpleguiqt" - FSG = "freesimplegui" """ - DEFAULT = "pysimplegui" + PSG = "pysimplegui" WEB = "pysimpleguiweb" QT = "pysimpleguiqt" FSG = "freesimplegui" + FSGWEB = "freesimpleguiweb" + FSGQT = "freesimpleguiqt" + DPG = "dearpygui" diff --git a/cli2gui/tojson/__init__.py b/cli2gui/tojson/__init__.py index e69de29..607c2d6 100644 --- a/cli2gui/tojson/__init__.py +++ b/cli2gui/tojson/__init__.py @@ -0,0 +1,2 @@ +"""Package containing transforms for each supported parser/cli library, responsible for +taking each parser representation (and BuildSpec) and generating a FullBuildSpec.""" diff --git a/cli2gui/tojson/argparse2json.py b/cli2gui/tojson/argparse2json.py index 272b908..ebbaba7 100644 --- a/cli2gui/tojson/argparse2json.py +++ b/cli2gui/tojson/argparse2json.py @@ -20,7 +20,7 @@ from sys import argv from typing import Any, Generator, TypedDict -from cli2gui.types import Group, Item, ItemType, ParserRep +from cli2gui.models import Group, Item, ItemType, ParserRep class ArgparseGroup(TypedDict): @@ -109,6 +109,7 @@ def extractRawGroups(actionGroup: argparse._ArgumentGroup) -> ArgparseGroup: def fileActionToJson(action: argparse.Action, widget: ItemType) -> Item: + """Convert an action of type Path or argparse.FileType to an Item.""" item = actionToJson(action=action, widget=widget) if isinstance(action.type, argparse.FileType): item.additional_properties = { @@ -166,12 +167,12 @@ def categorizeItems( elif isinstance(action.type, argparse.FileType): yield fileActionToJson(action, ItemType.File) - elif action.type == Path: + elif action.type is Path: yield actionToJson(action, ItemType.Path) - elif action.type == int: + elif action.type is int: yield actionToJson(action, ItemType.Int) - elif action.type == float: + elif action.type is float: yield actionToJson(action, ItemType.Float) else: yield actionToJson(action, ItemType.Text) diff --git a/cli2gui/tojson/click2json.py b/cli2gui/tojson/click2json.py index 7e2a3be..158473b 100644 --- a/cli2gui/tojson/click2json.py +++ b/cli2gui/tojson/click2json.py @@ -5,7 +5,7 @@ import contextlib from typing import Any, Generator -from cli2gui.types import Group, Item, ItemType, ParserRep +from cli2gui.models import Group, Item, ItemType, ParserRep def extract(parser: Any) -> list[Group]: diff --git a/cli2gui/tojson/docopt2json.py b/cli2gui/tojson/docopt2json.py index 244401b..942e0b0 100644 --- a/cli2gui/tojson/docopt2json.py +++ b/cli2gui/tojson/docopt2json.py @@ -5,7 +5,7 @@ import re from typing import Any, Iterator -from cli2gui.types import Group, Item, ItemType, ParserRep +from cli2gui.models import Group, Item, ItemType, ParserRep def actionToJson(action: tuple[str, str, int, Any, str], widget: ItemType, *, isPos: bool) -> Item: @@ -94,8 +94,8 @@ def parse(optionDescription: str) -> tuple[str, str, int, Any, str]: def parseOpt(doc: Any) -> list[tuple[str, str, int, Any, str]]: """Parse an option help text, adapted from docopt.""" defaults = [] - for section in parseSection("options:", doc): - _, _, section = section.partition(":") + for _section in parseSection("options:", doc): + _, _, section = _section.partition(":") split = re.split(r"\n[ \t]*(-\S+?)", "\n" + section)[1:] split = [s1 + s2 for s1, s2 in zip(split[::2], split[1::2])] options = [parse(s) for s in split if s.startswith("-")] @@ -106,8 +106,8 @@ def parseOpt(doc: Any) -> list[tuple[str, str, int, Any, str]]: def parsePos(doc: str) -> list[tuple[str, str]]: """Parse positional arguments from docstring.""" defaults = [] - for section in parseSection("arguments:", doc): - _, _, section = section.partition(":") + for _section in parseSection("arguments:", doc): + _, _, section = _section.partition(":") defaults.append( tuple(col.strip() for col in section.strip().partition(" ") if len(col.strip()) > 0) ) diff --git a/cli2gui/tojson/getopt2json.py b/cli2gui/tojson/getopt2json.py index 60b1fbf..2df4cbd 100644 --- a/cli2gui/tojson/getopt2json.py +++ b/cli2gui/tojson/getopt2json.py @@ -5,7 +5,7 @@ from collections.abc import Callable from typing import Generator -from cli2gui.types import Group, Item, ItemType, ParserRep +from cli2gui.models import Group, Item, ItemType, ParserRep # ruff: noqa: SLF001 diff --git a/cli2gui/tojson/optparse2json.py b/cli2gui/tojson/optparse2json.py index 1d09ecc..2da4398 100644 --- a/cli2gui/tojson/optparse2json.py +++ b/cli2gui/tojson/optparse2json.py @@ -9,7 +9,7 @@ import optparse from typing import Generator -from cli2gui.types import Group, Item, ItemType, ParserRep +from cli2gui.models import Group, Item, ItemType, ParserRep def extractOptions(optionGroup: optparse.OptionGroup) -> Group: diff --git a/documentation/reference/README.md b/documentation/reference/README.md index 039f84e..dd61655 100644 --- a/documentation/reference/README.md +++ b/documentation/reference/README.md @@ -14,10 +14,10 @@ A full list of `Cli2gui` project modules. - [DearPyGuiWrapper](cli2gui/gui/dearpygui_wrapper.md#dearpyguiwrapper) - [Helpers](cli2gui/gui/helpers.md#helpers) - [PySimpleGUIWrapper](cli2gui/gui/pysimplegui_wrapper.md#pysimpleguiwrapper) + - [Models](cli2gui/models.md#models) - [Tojson](cli2gui/tojson/index.md#tojson) - [Argparse2json](cli2gui/tojson/argparse2json.md#argparse2json) - [Click2json](cli2gui/tojson/click2json.md#click2json) - [Docopt2json](cli2gui/tojson/docopt2json.md#docopt2json) - [Getopt2json](cli2gui/tojson/getopt2json.md#getopt2json) - [Optparse2json](cli2gui/tojson/optparse2json.md#optparse2json) - - [Types](cli2gui/types.md#types) diff --git a/documentation/reference/cli2gui/application/application.md b/documentation/reference/cli2gui/application/application.md index 616ce05..11fc0c7 100644 --- a/documentation/reference/cli2gui/application/application.md +++ b/documentation/reference/cli2gui/application/application.md @@ -22,5 +22,5 @@ Establish the main entry point. #### Signature ```python -def run(buildSpec: types.FullBuildSpec) -> Any: ... +def run(buildSpec: models.FullBuildSpec) -> Any: ... ``` \ No newline at end of file diff --git a/documentation/reference/cli2gui/decorators.md b/documentation/reference/cli2gui/decorators.md index 2cd0ef3..3a772e6 100644 --- a/documentation/reference/cli2gui/decorators.md +++ b/documentation/reference/cli2gui/decorators.md @@ -169,5 +169,5 @@ def createFromParser( #### See also -- [BuildSpec](./types.md#buildspec) -- [FullBuildSpec](./types.md#fullbuildspec) \ No newline at end of file +- [BuildSpec](./models.md#buildspec) +- [FullBuildSpec](./models.md#fullbuildspec) \ No newline at end of file diff --git a/documentation/reference/cli2gui/gui/abstract_gui.md b/documentation/reference/cli2gui/gui/abstract_gui.md index eaa1833..05c0bd4 100644 --- a/documentation/reference/cli2gui/gui/abstract_gui.md +++ b/documentation/reference/cli2gui/gui/abstract_gui.md @@ -10,7 +10,7 @@ ## AbstractGUI -[Show source in abstract_gui.py:8](../../../../cli2gui/gui/abstract_gui.py#L8) +[Show source in abstract_gui.py:11](../../../../cli2gui/gui/abstract_gui.py#L11) Abstract base class for GUI wrappers. @@ -24,7 +24,7 @@ class AbstractGUI(ABC): ### AbstractGUI().main -[Show source in abstract_gui.py:15](../../../../cli2gui/gui/abstract_gui.py#L15) +[Show source in abstract_gui.py:18](../../../../cli2gui/gui/abstract_gui.py#L18) Abstract method for the main function. @@ -33,6 +33,9 @@ Abstract method for the main function. ```python @abstractmethod def main( - self, buildSpec: types.FullBuildSpec, menu: list[str], quit_callback, run_callback + self, + buildSpec: models.FullBuildSpec, + quit_callback: Callable[[], None], + run_callback: Callable[[dict[str, Any]], None], ) -> None: ... ``` \ No newline at end of file diff --git a/documentation/reference/cli2gui/gui/dearpygui_wrapper.md b/documentation/reference/cli2gui/gui/dearpygui_wrapper.md index c04310f..bee97be 100644 --- a/documentation/reference/cli2gui/gui/dearpygui_wrapper.md +++ b/documentation/reference/cli2gui/gui/dearpygui_wrapper.md @@ -15,7 +15,7 @@ ## DearPyGuiWrapper -[Show source in dearpygui_wrapper.py:24](../../../../cli2gui/gui/dearpygui_wrapper.py#L24) +[Show source in dearpygui_wrapper.py:26](../../../../cli2gui/gui/dearpygui_wrapper.py#L26) Wrapper class for Dear PyGui. @@ -32,7 +32,7 @@ class DearPyGuiWrapper(AbstractGUI): ### DearPyGuiWrapper()._helpFileWidget -[Show source in dearpygui_wrapper.py:73](../../../../cli2gui/gui/dearpygui_wrapper.py#L73) +[Show source in dearpygui_wrapper.py:80](../../../../cli2gui/gui/dearpygui_wrapper.py#L80) Create a UI element with an input text field and a file picker. @@ -44,11 +44,11 @@ def _helpFileWidget(self, item: Item) -> None: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) ### DearPyGuiWrapper().addItemsAndGroups -[Show source in dearpygui_wrapper.py:140](../../../../cli2gui/gui/dearpygui_wrapper.py#L140) +[Show source in dearpygui_wrapper.py:147](../../../../cli2gui/gui/dearpygui_wrapper.py#L147) Items and groups and return a list of these so we can get values from the dpg widgets. @@ -69,12 +69,12 @@ def addItemsAndGroups(self, section: Group) -> list[Item]: ... #### See also -- [Group](../types.md#group) -- [Item](../types.md#item) +- [Group](../models.md#group) +- [Item](../models.md#item) ### DearPyGuiWrapper().addWidgetFromItem -[Show source in dearpygui_wrapper.py:118](../../../../cli2gui/gui/dearpygui_wrapper.py#L118) +[Show source in dearpygui_wrapper.py:125](../../../../cli2gui/gui/dearpygui_wrapper.py#L125) Select a widget based on the item type. @@ -90,11 +90,11 @@ def addWidgetFromItem(self, item: Item) -> None: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) ### DearPyGuiWrapper().main -[Show source in dearpygui_wrapper.py:184](../../../../cli2gui/gui/dearpygui_wrapper.py#L184) +[Show source in dearpygui_wrapper.py:191](../../../../cli2gui/gui/dearpygui_wrapper.py#L191) Run the gui (dpg) with a given buildSpec, quit_callback, and run_callback. @@ -122,11 +122,11 @@ def main( #### See also -- [FullBuildSpec](../types.md#fullbuildspec) +- [FullBuildSpec](../models.md#fullbuildspec) ### DearPyGuiWrapper().open_menu_item -[Show source in dearpygui_wrapper.py:170](../../../../cli2gui/gui/dearpygui_wrapper.py#L170) +[Show source in dearpygui_wrapper.py:177](../../../../cli2gui/gui/dearpygui_wrapper.py#L177) Open a menu item. @@ -145,7 +145,7 @@ def open_menu_item(self, sender: str, _app_data: None) -> None: ... ## hex_to_rgb -[Show source in dearpygui_wrapper.py:15](../../../../cli2gui/gui/dearpygui_wrapper.py#L15) +[Show source in dearpygui_wrapper.py:17](../../../../cli2gui/gui/dearpygui_wrapper.py#L17) Convert a color hex code to a tuple of integers (r, g, b). diff --git a/documentation/reference/cli2gui/gui/helpers.md b/documentation/reference/cli2gui/gui/helpers.md index 306d902..3ffb8de 100644 --- a/documentation/reference/cli2gui/gui/helpers.md +++ b/documentation/reference/cli2gui/gui/helpers.md @@ -14,7 +14,7 @@ ## _themeFromFile -[Show source in helpers.py:17](../../../../cli2gui/gui/helpers.py#L17) +[Show source in helpers.py:20](../../../../cli2gui/gui/helpers.py#L20) Set the base24 theme from a base24 scheme.yaml to the application. @@ -38,7 +38,7 @@ def _themeFromFile(themeFile: str) -> list[str]: ... ## get_base24_theme -[Show source in helpers.py:33](../../../../cli2gui/gui/helpers.py#L33) +[Show source in helpers.py:36](../../../../cli2gui/gui/helpers.py#L36) Set the base24 theme to the application. @@ -60,7 +60,7 @@ def get_base24_theme( ## isDarkMode -[Show source in helpers.py:9](../../../../cli2gui/gui/helpers.py#L9) +[Show source in helpers.py:12](../../../../cli2gui/gui/helpers.py#L12) Monkeypatch for getostheme.isDarkMode. @@ -74,7 +74,7 @@ def isDarkMode() -> bool: ... ## read_file -[Show source in helpers.py:130](../../../../cli2gui/gui/helpers.py#L130) +[Show source in helpers.py:133](../../../../cli2gui/gui/helpers.py#L133) Get the contents of a file path, attempt to parse with catpandoc..pandoc2plain. @@ -97,7 +97,7 @@ def read_file(file_path: str, maxLines: int = 200) -> str: ... ## stringSentencecase -[Show source in helpers.py:122](../../../../cli2gui/gui/helpers.py#L122) +[Show source in helpers.py:125](../../../../cli2gui/gui/helpers.py#L125) Convert a string to sentence case. @@ -111,7 +111,7 @@ def stringSentencecase(string: str) -> str: ... ## stringTitlecase -[Show source in helpers.py:108](../../../../cli2gui/gui/helpers.py#L108) +[Show source in helpers.py:111](../../../../cli2gui/gui/helpers.py#L111) Convert a string to title case. diff --git a/documentation/reference/cli2gui/gui/pysimplegui_wrapper.md b/documentation/reference/cli2gui/gui/pysimplegui_wrapper.md index aab0a01..47d0d15 100644 --- a/documentation/reference/cli2gui/gui/pysimplegui_wrapper.md +++ b/documentation/reference/cli2gui/gui/pysimplegui_wrapper.md @@ -48,7 +48,7 @@ class PySimpleGUIWrapper(AbstractGUI): ### PySimpleGUIWrapper()._button -[Show source in pysimplegui_wrapper.py:103](../../../../cli2gui/gui/pysimplegui_wrapper.py#L103) +[Show source in pysimplegui_wrapper.py:109](../../../../cli2gui/gui/pysimplegui_wrapper.py#L109) Return a button. @@ -60,7 +60,7 @@ def _button(self, text: str) -> Any: ... ### PySimpleGUIWrapper()._check -[Show source in pysimplegui_wrapper.py:93](../../../../cli2gui/gui/pysimplegui_wrapper.py#L93) +[Show source in pysimplegui_wrapper.py:99](../../../../cli2gui/gui/pysimplegui_wrapper.py#L99) Return a checkbox. @@ -72,7 +72,7 @@ def _check(self, key: str, default: str | None = None) -> Any: ... ### PySimpleGUIWrapper()._dropdown -[Show source in pysimplegui_wrapper.py:124](../../../../cli2gui/gui/pysimplegui_wrapper.py#L124) +[Show source in pysimplegui_wrapper.py:130](../../../../cli2gui/gui/pysimplegui_wrapper.py#L130) Return a dropdown. @@ -84,7 +84,7 @@ def _dropdown(self, key: str, argItems: list[str]) -> Any: ... ### PySimpleGUIWrapper()._fileBrowser -[Show source in pysimplegui_wrapper.py:133](../../../../cli2gui/gui/pysimplegui_wrapper.py#L133) +[Show source in pysimplegui_wrapper.py:139](../../../../cli2gui/gui/pysimplegui_wrapper.py#L139) Return a fileBrowser button and field. @@ -102,11 +102,11 @@ def _fileBrowser( #### See also -- [ItemType](../types.md#itemtype) +- [ItemType](../models.md#itemtype) ### PySimpleGUIWrapper()._helpArgHelp -[Show source in pysimplegui_wrapper.py:182](../../../../cli2gui/gui/pysimplegui_wrapper.py#L182) +[Show source in pysimplegui_wrapper.py:188](../../../../cli2gui/gui/pysimplegui_wrapper.py#L188) Return a label for the arg help text. @@ -118,7 +118,7 @@ def _helpArgHelp(self, helpText: str) -> Any: ... ### PySimpleGUIWrapper()._helpArgName -[Show source in pysimplegui_wrapper.py:178](../../../../cli2gui/gui/pysimplegui_wrapper.py#L178) +[Show source in pysimplegui_wrapper.py:184](../../../../cli2gui/gui/pysimplegui_wrapper.py#L184) Return a label for the arg name. @@ -130,7 +130,7 @@ def _helpArgName(self, displayName: str, commands: list[str]) -> Any: ... ### PySimpleGUIWrapper()._helpArgNameAndHelp -[Show source in pysimplegui_wrapper.py:186](../../../../cli2gui/gui/pysimplegui_wrapper.py#L186) +[Show source in pysimplegui_wrapper.py:192](../../../../cli2gui/gui/pysimplegui_wrapper.py#L192) Return a column containing the argument name and help text. @@ -144,7 +144,7 @@ def _helpArgNameAndHelp( ### PySimpleGUIWrapper()._helpCounterWidget -[Show source in pysimplegui_wrapper.py:237](../../../../cli2gui/gui/pysimplegui_wrapper.py#L237) +[Show source in pysimplegui_wrapper.py:243](../../../../cli2gui/gui/pysimplegui_wrapper.py#L243) Return a set of self that make up an arg with text. @@ -156,11 +156,11 @@ def _helpCounterWidget(self, item: Item) -> list[Any]: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) ### PySimpleGUIWrapper()._helpDropdownWidget -[Show source in pysimplegui_wrapper.py:262](../../../../cli2gui/gui/pysimplegui_wrapper.py#L262) +[Show source in pysimplegui_wrapper.py:268](../../../../cli2gui/gui/pysimplegui_wrapper.py#L268) Return a set of self that make up an arg with a choice. @@ -172,11 +172,11 @@ def _helpDropdownWidget(self, item: Item) -> list[Any]: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) ### PySimpleGUIWrapper()._helpFileWidget -[Show source in pysimplegui_wrapper.py:249](../../../../cli2gui/gui/pysimplegui_wrapper.py#L249) +[Show source in pysimplegui_wrapper.py:255](../../../../cli2gui/gui/pysimplegui_wrapper.py#L255) Return a set of self that make up an arg with a file. @@ -188,11 +188,11 @@ def _helpFileWidget(self, item: Item) -> list[Any]: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) ### PySimpleGUIWrapper()._helpFlagWidget -[Show source in pysimplegui_wrapper.py:212](../../../../cli2gui/gui/pysimplegui_wrapper.py#L212) +[Show source in pysimplegui_wrapper.py:218](../../../../cli2gui/gui/pysimplegui_wrapper.py#L218) Return a set of self that make up an arg with true/ false. @@ -204,11 +204,11 @@ def _helpFlagWidget(self, item: Item) -> list[Any]: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) ### PySimpleGUIWrapper()._helpTextWidget -[Show source in pysimplegui_wrapper.py:224](../../../../cli2gui/gui/pysimplegui_wrapper.py#L224) +[Show source in pysimplegui_wrapper.py:230](../../../../cli2gui/gui/pysimplegui_wrapper.py#L230) Return a set of self that make up an arg with text. @@ -220,11 +220,11 @@ def _helpTextWidget(self, item: Item) -> list[Any]: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) ### PySimpleGUIWrapper()._inputText -[Show source in pysimplegui_wrapper.py:72](../../../../cli2gui/gui/pysimplegui_wrapper.py#L72) +[Show source in pysimplegui_wrapper.py:78](../../../../cli2gui/gui/pysimplegui_wrapper.py#L78) Return an input text field. @@ -236,7 +236,7 @@ def _inputText(self, key: str, default: str | None = None) -> Any: ... ### PySimpleGUIWrapper()._label -[Show source in pysimplegui_wrapper.py:112](../../../../cli2gui/gui/pysimplegui_wrapper.py#L112) +[Show source in pysimplegui_wrapper.py:118](../../../../cli2gui/gui/pysimplegui_wrapper.py#L118) Return a label. @@ -248,7 +248,7 @@ def _label(self, text: str, font: int = 11) -> Any: ... ### PySimpleGUIWrapper()._spin -[Show source in pysimplegui_wrapper.py:82](../../../../cli2gui/gui/pysimplegui_wrapper.py#L82) +[Show source in pysimplegui_wrapper.py:88](../../../../cli2gui/gui/pysimplegui_wrapper.py#L88) Return an input text field. @@ -260,7 +260,7 @@ def _spin(self, key: str, default: str | None = None) -> Any: ... ### PySimpleGUIWrapper()._title -[Show source in pysimplegui_wrapper.py:193](../../../../cli2gui/gui/pysimplegui_wrapper.py#L193) +[Show source in pysimplegui_wrapper.py:199](../../../../cli2gui/gui/pysimplegui_wrapper.py#L199) Return a set of self that make up the application header. @@ -272,7 +272,7 @@ def _title(self, text: str, image: str = "") -> list[Any]: ... ### PySimpleGUIWrapper().addItemsAndGroups -[Show source in pysimplegui_wrapper.py:365](../../../../cli2gui/gui/pysimplegui_wrapper.py#L365) +[Show source in pysimplegui_wrapper.py:371](../../../../cli2gui/gui/pysimplegui_wrapper.py#L371) Items and groups and return a list of psg Elements. @@ -293,11 +293,11 @@ def addItemsAndGroups(self, section: Group) -> list[list[Any]]: ... #### See also -- [Group](../types.md#group) +- [Group](../models.md#group) ### PySimpleGUIWrapper().addWidgetFromItem -[Show source in pysimplegui_wrapper.py:281](../../../../cli2gui/gui/pysimplegui_wrapper.py#L281) +[Show source in pysimplegui_wrapper.py:287](../../../../cli2gui/gui/pysimplegui_wrapper.py#L287) Select a widget based on the item type. @@ -313,24 +313,23 @@ def addWidgetFromItem(self, item: Item) -> list[Any]: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) ### PySimpleGUIWrapper().createLayout -[Show source in pysimplegui_wrapper.py:390](../../../../cli2gui/gui/pysimplegui_wrapper.py#L390) +[Show source in pysimplegui_wrapper.py:396](../../../../cli2gui/gui/pysimplegui_wrapper.py#L396) Create the pysimplegui layout from the build spec. #### Arguments ----- - - `buildSpec` *FullBuildSpec* - build spec containing widget - - `self` *self* - class to build self +- `buildSpec` *FullBuildSpec* - build spec containing widget +:param str | list[str] menu: menu definition. containing menu keys #### Returns -------- - - `list[list[Any]]` - list of self (layout list) +Type: *list[list[Any]]* +list of self (layout list) #### Signature @@ -342,11 +341,11 @@ def createLayout( #### See also -- [FullBuildSpec](../types.md#fullbuildspec) +- [FullBuildSpec](../models.md#fullbuildspec) ### PySimpleGUIWrapper().generatePopup -[Show source in pysimplegui_wrapper.py:305](../../../../cli2gui/gui/pysimplegui_wrapper.py#L305) +[Show source in pysimplegui_wrapper.py:311](../../../../cli2gui/gui/pysimplegui_wrapper.py#L311) Create the popup window. @@ -372,11 +371,11 @@ def generatePopup( #### See also -- [FullBuildSpec](../types.md#fullbuildspec) +- [FullBuildSpec](../models.md#fullbuildspec) ### PySimpleGUIWrapper().getImgData -[Show source in pysimplegui_wrapper.py:507](../../../../cli2gui/gui/pysimplegui_wrapper.py#L507) +[Show source in pysimplegui_wrapper.py:508](../../../../cli2gui/gui/pysimplegui_wrapper.py#L508) Generate image data using PIL. @@ -388,7 +387,7 @@ def getImgData(self, imagePath: str, first: bool = False) -> bytes: ... ### PySimpleGUIWrapper().main -[Show source in pysimplegui_wrapper.py:462](../../../../cli2gui/gui/pysimplegui_wrapper.py#L462) +[Show source in pysimplegui_wrapper.py:463](../../../../cli2gui/gui/pysimplegui_wrapper.py#L463) Run the gui (psg) with a given buildSpec, quit_callback, and run_callback. @@ -411,4 +410,4 @@ def main( #### See also -- [FullBuildSpec](../types.md#fullbuildspec) \ No newline at end of file +- [FullBuildSpec](../models.md#fullbuildspec) \ No newline at end of file diff --git a/documentation/reference/cli2gui/index.md b/documentation/reference/cli2gui/index.md index 42a9088..0342617 100644 --- a/documentation/reference/cli2gui/index.md +++ b/documentation/reference/cli2gui/index.md @@ -12,5 +12,5 @@ - [Application](application/index.md) - [Decorators](./decorators.md) - [Gui](gui/index.md) -- [Tojson](tojson/index.md) -- [Types](./types.md) \ No newline at end of file +- [Models](./models.md) +- [Tojson](tojson/index.md) \ No newline at end of file diff --git a/documentation/reference/cli2gui/types.md b/documentation/reference/cli2gui/models.md similarity index 54% rename from documentation/reference/cli2gui/types.md rename to documentation/reference/cli2gui/models.md index 4767dd0..c290cdf 100644 --- a/documentation/reference/cli2gui/types.md +++ b/documentation/reference/cli2gui/models.md @@ -1,10 +1,10 @@ -# Types +# Models -[Cli2gui Index](../README.md#cli2gui-index) / [Cli2gui](./index.md#cli2gui) / Types +[Cli2gui Index](../README.md#cli2gui-index) / [Cli2gui](./index.md#cli2gui) / Models -> Auto-generated documentation for [cli2gui.types](../../../cli2gui/types.py) module. +> Auto-generated documentation for [cli2gui.models](../../../cli2gui/models.py) module. -- [Types](#types) +- [Models](#models) - [BuildSpec](#buildspec) - [FullBuildSpec](#fullbuildspec) - [GUIType](#guitype) @@ -16,7 +16,7 @@ ## BuildSpec -[Show source in types.py:14](../../../cli2gui/types.py#L14) +[Show source in models.py:14](../../../cli2gui/models.py#L14) Representation for the BuildSpec. @@ -30,7 +30,7 @@ class BuildSpec: ... ## FullBuildSpec -[Show source in types.py:80](../../../cli2gui/types.py#L80) +[Show source in models.py:80](../../../cli2gui/models.py#L80) Representation for the FullBuildSpec (BuildSpec + ParserRep). @@ -44,15 +44,10 @@ class FullBuildSpec: ... ## GUIType -[Show source in types.py:120](../../../cli2gui/types.py#L120) +[Show source in models.py:113](../../../cli2gui/models.py#L113) Supported gui types. -DEFAULT = "pysimplegui" -WEB = "pysimpleguiweb" -QT = "pysimpleguiqt" -FSG = "freesimplegui" - #### Signature ```python @@ -63,7 +58,7 @@ class GUIType(str, Enum): ... ## Group -[Show source in types.py:63](../../../cli2gui/types.py#L63) +[Show source in models.py:63](../../../cli2gui/models.py#L63) Representation for an argument group. @@ -77,7 +72,7 @@ class Group: ... ## Item -[Show source in types.py:30](../../../cli2gui/types.py#L30) +[Show source in models.py:30](../../../cli2gui/models.py#L30) Representation for an arg_item. @@ -91,7 +86,7 @@ class Item: ... ## ItemType -[Show source in types.py:45](../../../cli2gui/types.py#L45) +[Show source in models.py:45](../../../cli2gui/models.py#L45) Enum of ItemTypes. @@ -105,7 +100,7 @@ class ItemType(Enum): ... ## ParserRep -[Show source in types.py:72](../../../cli2gui/types.py#L72) +[Show source in models.py:72](../../../cli2gui/models.py#L72) Representation for a parser. @@ -119,18 +114,10 @@ class ParserRep: ... ## ParserType -[Show source in types.py:98](../../../cli2gui/types.py#L98) +[Show source in models.py:98](../../../cli2gui/models.py#L98) Supported parser types. -OPTPARSE = "optparse" -ARGPARSE = "argparse" -DEPHELL_ARGPARSE = "dephell_argparse" -DOCOPT = "docopt" -GETOPT = "getopt" -CLICK = "click" -CUSTOM = "input()" # this seems like a pretty poor pattern to use - #### Signature ```python diff --git a/documentation/reference/cli2gui/tojson/argparse2json.md b/documentation/reference/cli2gui/tojson/argparse2json.md index ac624fb..7783084 100644 --- a/documentation/reference/cli2gui/tojson/argparse2json.md +++ b/documentation/reference/cli2gui/tojson/argparse2json.md @@ -37,7 +37,7 @@ class ArgparseGroup(TypedDict): ... ## actionToJson -[Show source in argparse2json.py:122](../../../../cli2gui/tojson/argparse2json.py#L122) +[Show source in argparse2json.py:123](../../../../cli2gui/tojson/argparse2json.py#L123) Generate json for an action and set the widget - used by the application. @@ -49,14 +49,14 @@ def actionToJson(action: argparse.Action, widget: ItemType) -> Item: ... #### See also -- [ItemType](../types.md#itemtype) -- [Item](../types.md#item) +- [ItemType](../models.md#itemtype) +- [Item](../models.md#item) ## buildRadioGroup -[Show source in argparse2json.py:136](../../../../cli2gui/tojson/argparse2json.py#L136) +[Show source in argparse2json.py:137](../../../../cli2gui/tojson/argparse2json.py#L137) Create a radio group for a mutex group of arguments. @@ -68,13 +68,13 @@ def buildRadioGroup(mutexGroup: _MutuallyExclusiveGroup) -> Item: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) ## categorizeGroups -[Show source in argparse2json.py:180](../../../../cli2gui/tojson/argparse2json.py#L180) +[Show source in argparse2json.py:181](../../../../cli2gui/tojson/argparse2json.py#L181) Categorize the parser groups and arg_items. @@ -87,13 +87,13 @@ def categorizeGroups(groups: list[ArgparseGroup]) -> list[Group]: ... #### See also - [ArgparseGroup](#argparsegroup) -- [Group](../types.md#group) +- [Group](../models.md#group) ## categorizeItems -[Show source in argparse2json.py:150](../../../../cli2gui/tojson/argparse2json.py#L150) +[Show source in argparse2json.py:151](../../../../cli2gui/tojson/argparse2json.py#L151) Catergorise each action and generate json. @@ -105,7 +105,7 @@ def categorizeItems(actions: list[argparse.Action]) -> Generator[Item, None, Non #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) @@ -141,7 +141,7 @@ def containsActions( ## convert -[Show source in argparse2json.py:207](../../../../cli2gui/tojson/argparse2json.py#L207) +[Show source in argparse2json.py:208](../../../../cli2gui/tojson/argparse2json.py#L208) Convert argparse to a dict. @@ -163,7 +163,7 @@ def convert(parser: argparse.ArgumentParser) -> ParserRep: ... #### See also -- [ParserRep](../types.md#parserrep) +- [ParserRep](../models.md#parserrep) @@ -189,6 +189,8 @@ def extractRawGroups(actionGroup: argparse._ArgumentGroup) -> ArgparseGroup: ... [Show source in argparse2json.py:111](../../../../cli2gui/tojson/argparse2json.py#L111) +Convert an action of type Path or argparse.FileType to an Item. + #### Signature ```python @@ -197,8 +199,8 @@ def fileActionToJson(action: argparse.Action, widget: ItemType) -> Item: ... #### See also -- [ItemType](../types.md#itemtype) -- [Item](../types.md#item) +- [ItemType](../models.md#itemtype) +- [Item](../models.md#item) @@ -234,7 +236,7 @@ def iterParsers( ## process -[Show source in argparse2json.py:197](../../../../cli2gui/tojson/argparse2json.py#L197) +[Show source in argparse2json.py:198](../../../../cli2gui/tojson/argparse2json.py#L198) Reapply the mutex groups and then categorize them and the arg_items under the parser. @@ -246,7 +248,7 @@ def process(parser: argparse.ArgumentParser) -> list[Group]: ... #### See also -- [Group](../types.md#group) +- [Group](../models.md#group) @@ -275,7 +277,7 @@ def reapplyMutexGroups( ## stripEmpty -[Show source in argparse2json.py:192](../../../../cli2gui/tojson/argparse2json.py#L192) +[Show source in argparse2json.py:193](../../../../cli2gui/tojson/argparse2json.py#L193) Remove groups where group['arg_items'] is false. diff --git a/documentation/reference/cli2gui/tojson/click2json.md b/documentation/reference/cli2gui/tojson/click2json.md index 658e592..5a0e7eb 100644 --- a/documentation/reference/cli2gui/tojson/click2json.md +++ b/documentation/reference/cli2gui/tojson/click2json.md @@ -24,8 +24,8 @@ def actionToJson(action: Any, widget: ItemType, other: dict | None = None) -> It #### See also -- [ItemType](../types.md#itemtype) -- [Item](../types.md#item) +- [ItemType](../models.md#itemtype) +- [Item](../models.md#item) @@ -43,7 +43,7 @@ def categorize(actions: list[Any]) -> Generator[Item, None, None]: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) @@ -71,7 +71,7 @@ def convert(parser: Any) -> ParserRep: ... #### See also -- [ParserRep](../types.md#parserrep) +- [ParserRep](../models.md#parserrep) @@ -89,4 +89,4 @@ def extract(parser: Any) -> list[Group]: ... #### See also -- [Group](../types.md#group) \ No newline at end of file +- [Group](../models.md#group) \ No newline at end of file diff --git a/documentation/reference/cli2gui/tojson/docopt2json.md b/documentation/reference/cli2gui/tojson/docopt2json.md index 7a41e4a..63161ae 100644 --- a/documentation/reference/cli2gui/tojson/docopt2json.md +++ b/documentation/reference/cli2gui/tojson/docopt2json.md @@ -30,8 +30,8 @@ def actionToJson( #### See also -- [ItemType](../types.md#itemtype) -- [Item](../types.md#item) +- [ItemType](../models.md#itemtype) +- [Item](../models.md#item) @@ -53,7 +53,7 @@ def categorize( #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) @@ -81,7 +81,7 @@ def convert(parser: Any) -> ParserRep: ... #### See also -- [ParserRep](../types.md#parserrep) +- [ParserRep](../models.md#parserrep) @@ -99,7 +99,7 @@ def extract(parser: Any) -> list[Group]: ... #### See also -- [Group](../types.md#group) +- [Group](../models.md#group) diff --git a/documentation/reference/cli2gui/tojson/getopt2json.md b/documentation/reference/cli2gui/tojson/getopt2json.md index c124fc9..f5cd62d 100644 --- a/documentation/reference/cli2gui/tojson/getopt2json.md +++ b/documentation/reference/cli2gui/tojson/getopt2json.md @@ -26,8 +26,8 @@ def actionToJson(action: str, widget: ItemType, short: bool = True) -> Item: ... #### See also -- [ItemType](../types.md#itemtype) -- [Item](../types.md#item) +- [ItemType](../models.md#itemtype) +- [Item](../models.md#item) @@ -45,7 +45,7 @@ def catLong(actions: list[str]) -> Generator[Item, None, None]: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) @@ -63,7 +63,7 @@ def catShort(actions: list[str]) -> Generator[Item, None, None]: ... #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) @@ -91,7 +91,7 @@ def convert(parser: tuple[list[str], list[str]]) -> ParserRep: ... #### See also -- [ParserRep](../types.md#parserrep) +- [ParserRep](../models.md#parserrep) @@ -113,5 +113,5 @@ def process( #### See also -- [Group](../types.md#group) -- [Item](../types.md#item) \ No newline at end of file +- [Group](../models.md#group) +- [Item](../models.md#item) \ No newline at end of file diff --git a/documentation/reference/cli2gui/tojson/optparse2json.md b/documentation/reference/cli2gui/tojson/optparse2json.md index d281f5e..0f27efe 100644 --- a/documentation/reference/cli2gui/tojson/optparse2json.md +++ b/documentation/reference/cli2gui/tojson/optparse2json.md @@ -25,8 +25,8 @@ def actionToJson(action: optparse.Option, widget: ItemType) -> Item: ... #### See also -- [ItemType](../types.md#itemtype) -- [Item](../types.md#item) +- [ItemType](../models.md#itemtype) +- [Item](../models.md#item) @@ -44,7 +44,7 @@ def categorize(actions: list[optparse.Option]) -> Generator[Item, None, None]: . #### See also -- [Item](../types.md#item) +- [Item](../models.md#item) @@ -72,7 +72,7 @@ def convert(parser: optparse.OptionParser) -> ParserRep: ... #### See also -- [ParserRep](../types.md#parserrep) +- [ParserRep](../models.md#parserrep) @@ -90,7 +90,7 @@ def extractGroups(parser: optparse.OptionParser) -> Group: ... #### See also -- [Group](../types.md#group) +- [Group](../models.md#group) @@ -108,4 +108,4 @@ def extractOptions(optionGroup: optparse.OptionGroup) -> Group: ... #### See also -- [Group](../types.md#group) \ No newline at end of file +- [Group](../models.md#group) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index a1e7537..ffb9f4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,7 @@ target-version = "py38" [tool.ruff.lint] select = ["ALL"] ignore = [ + "ANN401", # allow dynamically typed expressions (typing.Any) "COM812", # enforce trailing comma "D2", # pydocstyle formatting "ISC001", @@ -78,7 +79,7 @@ ignore = [ fixable = ["ALL"] [tool.ruff.lint.per-file-ignores] -"**/{tests,docs,tools}/*" = ["D", "S101", "E402", "T201"] +"**/{tests,docs,tools}/*" = ["D", "S101", "E402", "T201", "ERA001"] [tool.ruff.lint.flake8-tidy-imports] ban-relative-imports = "all" # Disallow all relative imports. diff --git a/tests/argparse/test_18.py b/tests/argparse/test_18.py index 051f1ec..408d468 100644 --- a/tests/argparse/test_18.py +++ b/tests/argparse/test_18.py @@ -36,16 +36,16 @@ def main() -> None: blocking_run(args) -def blocking_run(args) -> None: +def blocking_run(args: argparse.Namespace) -> None: asyncio.run(run(args)) -async def run(args) -> None: +async def run(args: argparse.Namespace) -> None: print(args) print(args.timeout) -def wrapper(args) -> None: +def wrapper(args: argparse.Namespace) -> None: global THREAD if THREAD is not None and THREAD.is_alive(): diff --git a/tests/argparse/test_22.py b/tests/argparse/test_22.py index 19e8a16..9414aef 100644 --- a/tests/argparse/test_22.py +++ b/tests/argparse/test_22.py @@ -36,16 +36,16 @@ def main() -> None: blocking_run(args) -def blocking_run(args) -> None: +def blocking_run(args: argparse.Namespace) -> None: asyncio.run(run(args)) -async def run(args) -> None: +async def run(args: argparse.Namespace) -> None: print(args) print(args.timeout) -def wrapper(args) -> None: +def wrapper(args: argparse.Namespace) -> None: global THREAD if THREAD is not None and THREAD.is_alive():