Skip to content

Commit a96d130

Browse files
Merge pull request #28 from rjdbcm/main
Add type-hinting metadata to package build
2 parents 14fa456 + ca4eb61 commit a96d130

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

PyPI/Package/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ classifiers = [
1515
"Programming Language :: Python :: 3",
1616
"License :: OSI Approved :: MIT License",
1717
"Operating System :: OS Independent",
18+
"Typing :: Typed",
1819
]
1920

2021
[project.urls]

PyPI/Package/src/webui/load_library.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _download_library():
5656

5757

5858
# Load WebUI Dynamic Library
59-
def load_library() -> CDLL:
59+
def load_library() -> CDLL | None:
6060
library: CDLL | None = None
6161
lib_path = _get_library_path()
6262
if not os.path.exists(lib_path):
@@ -87,4 +87,4 @@ def load_library() -> CDLL:
8787
else:
8888
print("Unsupported OS")
8989

90-
return library
90+
return library

PyPI/Package/src/webui/py.typed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

PyPI/Package/src/webui/webui.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
from __future__ import annotations
1313

1414
import warnings
15-
from typing import Callable, Optional
15+
from typing import Any, Callable, Optional, TypeAlias
1616
from ctypes import *
1717

1818
# Import all the raw bindings
1919
from . import webui_bindings as _raw
2020

2121

22-
2322
# C function type for the file handler window
2423
filehandler_window_callback = CFUNCTYPE(c_void_p, c_size_t, c_char_p, POINTER(c_int))
2524

@@ -308,7 +307,7 @@ def script_client(self, script: str, timeout: int = 0, buffer_size: int = 4096)
308307
# Initializing Result
309308
res = JavaScript()
310309

311-
res.data = buffer.value.decode('utf-8', errors='ignore')
310+
res.data = buffer.value.decode('utf-8', errors='ignore') # type: ignore
312311
res.error = not success
313312
return res
314313

@@ -619,8 +618,8 @@ def __init__(self, window_id: Optional[int] = None):
619618
self._cb_func_list: dict = {}
620619

621620
# gets used for both filehandler and filehandler_window, should wipe out the other just how it does in C
622-
self._file_handler_cb: _raw.FILE_HANDLER_CB = None
623-
self._buffers = []
621+
self._file_handler_cb: Any = None
622+
self._buffers: list = []
624623

625624
# -- dispatcher for function bindings -----------
626625
def _make_dispatcher(self):
@@ -1051,7 +1050,7 @@ def send_raw(self, function: str, raw: Optional[c_void_p], size: int) -> None:
10511050
_raw.webui_send_raw(
10521051
c_size_t(self._window),
10531052
c_char_p(function.encode("utf-8")),
1054-
c_void_p(raw),
1053+
c_void_p(raw), # type: ignore
10551054
c_size_t(size)
10561055
)
10571056

@@ -1397,7 +1396,7 @@ def script(self, script: str, timeout: int = 0, buffer_size: int = 4096) -> Java
13971396
# Initializing Result
13981397
res = JavaScript()
13991398

1400-
res.data = buffer.value.decode('utf-8', errors='ignore')
1399+
res.data = buffer.value.decode('utf-8', errors='ignore') # type: ignore
14011400
res.error = not success
14021401
return res
14031402

0 commit comments

Comments
 (0)