From 691c651556c3d4924b43e5c2e82d97a2a5482c3c Mon Sep 17 00:00:00 2001 From: "Eden Ross Duff, MSc, DDiv" Date: Tue, 18 Feb 2025 15:45:18 -0600 Subject: [PATCH 1/5] Create py.typed --- PyPI/Package/src/webui/py.typed | 1 + 1 file changed, 1 insertion(+) create mode 100644 PyPI/Package/src/webui/py.typed diff --git a/PyPI/Package/src/webui/py.typed b/PyPI/Package/src/webui/py.typed new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/PyPI/Package/src/webui/py.typed @@ -0,0 +1 @@ + From 94f9bb7371e35d1b51b97fd55a7b1d2daa26ce94 Mon Sep 17 00:00:00 2001 From: "Eden Ross Duff, MSc, DDiv" Date: Tue, 18 Feb 2025 15:50:47 -0600 Subject: [PATCH 2/5] fix load_library.py:load_library() return type annotation --- PyPI/Package/src/webui/load_library.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PyPI/Package/src/webui/load_library.py b/PyPI/Package/src/webui/load_library.py index 3f59730..a849fb3 100644 --- a/PyPI/Package/src/webui/load_library.py +++ b/PyPI/Package/src/webui/load_library.py @@ -56,7 +56,7 @@ def _download_library(): # Load WebUI Dynamic Library -def load_library() -> CDLL: +def load_library() -> CDLL | None: library: CDLL | None = None lib_path = _get_library_path() if not os.path.exists(lib_path): @@ -87,4 +87,4 @@ def load_library() -> CDLL: else: print("Unsupported OS") - return library \ No newline at end of file + return library From a02f563581a7e1e4981a50943b9931786abdbc3e Mon Sep 17 00:00:00 2001 From: "Eden Ross Duff, MSc, DDiv" Date: Tue, 18 Feb 2025 16:03:18 -0600 Subject: [PATCH 3/5] clean up typing in main module --- PyPI/Package/src/webui/webui.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PyPI/Package/src/webui/webui.py b/PyPI/Package/src/webui/webui.py index 750814c..3a139dd 100644 --- a/PyPI/Package/src/webui/webui.py +++ b/PyPI/Package/src/webui/webui.py @@ -12,14 +12,14 @@ from __future__ import annotations import warnings -from typing import Callable, Optional +from typing import Callable, Optional, TypeAlias from ctypes import * # Import all the raw bindings from . import webui_bindings as _raw - +_FileHandlerCallback: TypeAlias = _raw.FILE_HANDLER_CB # C function type for the file handler window filehandler_window_callback = CFUNCTYPE(c_void_p, c_size_t, c_char_p, POINTER(c_int)) @@ -308,7 +308,7 @@ def script_client(self, script: str, timeout: int = 0, buffer_size: int = 4096) # Initializing Result res = JavaScript() - res.data = buffer.value.decode('utf-8', errors='ignore') + res.data = buffer.value.decode('utf-8', errors='ignore') # type: ignore res.error = not success return res @@ -619,8 +619,8 @@ def __init__(self, window_id: Optional[int] = None): self._cb_func_list: dict = {} # gets used for both filehandler and filehandler_window, should wipe out the other just how it does in C - self._file_handler_cb: _raw.FILE_HANDLER_CB = None - self._buffers = [] + self._file_handler_cb: _FileHandlerCallback = None + self._buffers: list = [] # -- dispatcher for function bindings ----------- def _make_dispatcher(self): @@ -1051,7 +1051,7 @@ def send_raw(self, function: str, raw: Optional[c_void_p], size: int) -> None: _raw.webui_send_raw( c_size_t(self._window), c_char_p(function.encode("utf-8")), - c_void_p(raw), + c_void_p(raw), # type: ignore c_size_t(size) ) @@ -1397,7 +1397,7 @@ def script(self, script: str, timeout: int = 0, buffer_size: int = 4096) -> Java # Initializing Result res = JavaScript() - res.data = buffer.value.decode('utf-8', errors='ignore') + res.data = buffer.value.decode('utf-8', errors='ignore') # type: ignore res.error = not success return res From 49e9e644c6887e2cdb38e77e3e0455cbd74c1157 Mon Sep 17 00:00:00 2001 From: "Eden Ross Duff, MSc, DDiv" Date: Tue, 18 Feb 2025 16:13:45 -0600 Subject: [PATCH 4/5] use Any for FILE_HANDLER_CB type --- PyPI/Package/src/webui/webui.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PyPI/Package/src/webui/webui.py b/PyPI/Package/src/webui/webui.py index 3a139dd..7d2aa02 100644 --- a/PyPI/Package/src/webui/webui.py +++ b/PyPI/Package/src/webui/webui.py @@ -12,14 +12,13 @@ from __future__ import annotations import warnings -from typing import Callable, Optional, TypeAlias +from typing import Any, Callable, Optional, TypeAlias from ctypes import * # Import all the raw bindings from . import webui_bindings as _raw -_FileHandlerCallback: TypeAlias = _raw.FILE_HANDLER_CB # C function type for the file handler window filehandler_window_callback = CFUNCTYPE(c_void_p, c_size_t, c_char_p, POINTER(c_int)) @@ -619,7 +618,7 @@ def __init__(self, window_id: Optional[int] = None): self._cb_func_list: dict = {} # gets used for both filehandler and filehandler_window, should wipe out the other just how it does in C - self._file_handler_cb: _FileHandlerCallback = None + self._file_handler_cb: Any = None self._buffers: list = [] # -- dispatcher for function bindings ----------- From ca4eb61e2f6294a01e671e0b9ac6a878a1145ff0 Mon Sep 17 00:00:00 2001 From: "Eden Ross Duff, MSc, DDiv" Date: Tue, 18 Feb 2025 16:15:48 -0600 Subject: [PATCH 5/5] add ``Typing :: Typed`` classifier --- PyPI/Package/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/PyPI/Package/pyproject.toml b/PyPI/Package/pyproject.toml index e5476af..b0145ff 100644 --- a/PyPI/Package/pyproject.toml +++ b/PyPI/Package/pyproject.toml @@ -15,6 +15,7 @@ classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", + "Typing :: Typed", ] [project.urls]