Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typing of pointer to support latest stubs #32

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/jack_server/_driver.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions src/jack_server/_jslist.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/jack_server/_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +34,7 @@ def get_library_name():

class JSList(Structure):
data: "_CData"
next: "pointer[JSList]"
next: "_Pointer[JSList]"


JSList_p = POINTER(JSList)
Expand Down
8 changes: 4 additions & 4 deletions src/jack_server/_parameter.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -75,7 +75,7 @@ def __repr__(self) -> str:
return f"<jack_server.Parameter name={self.name!r} value={self.value!r}>"


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):
Expand Down
4 changes: 2 additions & 2 deletions src/jack_server/_server.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down