From 9f869416e9b735670250867b71d3d7910f202a07 Mon Sep 17 00:00:00 2001 From: Lev Vereshchagin Date: Fri, 9 Sep 2022 18:35:43 +0300 Subject: [PATCH] Fix typing of pointer to support latest stubs --- src/jack_server/_driver.py | 6 +++--- src/jack_server/_jslist.py | 4 ++-- src/jack_server/_lib.py | 4 ++-- src/jack_server/_parameter.py | 8 ++++---- src/jack_server/_server.py | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/jack_server/_driver.py b/src/jack_server/_driver.py index 855434d..98438a3 100644 --- a/src/jack_server/_driver.py +++ b/src/jack_server/_driver.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ctypes import pointer +from ctypes import _Pointer from typing import Literal, cast import jack_server._lib as lib @@ -11,9 +11,9 @@ class Driver: params: dict[str, Parameter] - _ptr: pointer[lib.jackctl_driver_t] + _ptr: _Pointer[lib.jackctl_driver_t] - def __init__(self, ptr: pointer[lib.jackctl_driver_t]) -> None: + def __init__(self, ptr: _Pointer[lib.jackctl_driver_t]) -> None: self._ptr = ptr self._init_params() diff --git a/src/jack_server/_jslist.py b/src/jack_server/_jslist.py index 72ad11f..b6761b8 100644 --- a/src/jack_server/_jslist.py +++ b/src/jack_server/_jslist.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ctypes import cast, pointer +from ctypes import _Pointer, cast from typing import TYPE_CHECKING, Iterable, TypeVar import jack_server._lib as lib @@ -11,7 +11,7 @@ _T = TypeVar("_T", bound=_CanCastTo) -def iterate_jslist(ptr: pointer[lib.JSList], type: type[_T]) -> Iterable[_T]: +def iterate_jslist(ptr: _Pointer[lib.JSList], type: type[_T]) -> Iterable[_T]: cur_ptr = ptr while cur_ptr: diff --git a/src/jack_server/_lib.py b/src/jack_server/_lib.py index f30afd7..64979c9 100644 --- a/src/jack_server/_lib.py +++ b/src/jack_server/_lib.py @@ -4,13 +4,13 @@ POINTER, Structure, Union, + _Pointer, c_bool, c_char, c_char_p, c_int, c_uint, c_void_p, - pointer, ) from ctypes.util import find_library from typing import TYPE_CHECKING @@ -34,7 +34,7 @@ def get_library_name(): class JSList(Structure): data: "_CData" - next: "pointer[JSList]" + next: "_Pointer[JSList]" JSList_p = POINTER(JSList) diff --git a/src/jack_server/_parameter.py b/src/jack_server/_parameter.py index 035baea..033530d 100644 --- a/src/jack_server/_parameter.py +++ b/src/jack_server/_parameter.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ctypes import pointer +from ctypes import _Pointer, pointer from typing import Literal, Union, cast import jack_server._lib as lib @@ -10,10 +10,10 @@ class Parameter: - _ptr: pointer[lib.jackctl_parameter_t] + _ptr: _Pointer[lib.jackctl_parameter_t] type: Literal[1, 2, 3, 4, 5] - def __init__(self, ptr: pointer[lib.jackctl_parameter_t]) -> None: + def __init__(self, ptr: _Pointer[lib.jackctl_parameter_t]) -> None: self._ptr = ptr self.type = lib.jackctl_parameter_get_type(self._ptr) @@ -75,7 +75,7 @@ def __repr__(self) -> str: return f"" -def get_params_from_jslist(jslist: pointer[lib.JSList]) -> dict[str, Parameter]: +def get_params_from_jslist(jslist: _Pointer[lib.JSList]) -> dict[str, Parameter]: params: dict[str, Parameter] = {} for ptr in iterate_jslist(jslist, lib.jackctl_parameter_t_p): diff --git a/src/jack_server/_server.py b/src/jack_server/_server.py index 6a6c1b8..37dd3dd 100644 --- a/src/jack_server/_server.py +++ b/src/jack_server/_server.py @@ -1,6 +1,6 @@ from __future__ import annotations -from ctypes import pointer +from ctypes import _Pointer from typing import Callable, cast import jack_server._lib as lib @@ -35,7 +35,7 @@ class SetByJack: class Server: driver: Driver params: dict[str, Parameter] - _ptr: pointer[lib.jackctl_server_t] + _ptr: _Pointer[lib.jackctl_server_t] _created: bool _opened: bool _started: bool