1
1
import sys
2
2
from _typeshed import Self
3
3
from collections .abc import Callable , Generator , Iterable , Iterator , Sequence
4
- from typing import Any , overload
5
- from typing_extensions import Literal , TypeAlias
4
+ from typing import Any , NoReturn , overload
5
+ from typing_extensions import Literal
6
6
7
- _NDArray : TypeAlias = Any # FIXME: no typings for numpy arrays
7
+ import numpy
8
+ from _cffi_backend import _CDataBase
9
+ from numpy .typing import NDArray
8
10
9
- class _JackPositionT : ...
11
+ # Aka jack_position_t
12
+ # Actual type: _cffi_backend.__CDataOwn <cdata 'struct _jack_position *'>
13
+ # This is not a real subclassing. Just ensuring type-checkers sees this type as compatible with _CDataBase
14
+ # pyright has no error code for subclassing final
15
+ class _JackPositionT (_CDataBase ): # type: ignore[misc] # pyright: ignore
16
+ audio_frames_per_video_frame : float
17
+ bar : int
18
+ bar_start_tick : float
19
+ bbt_offset : int
20
+ beat : int
21
+ beat_type : float
22
+ beats_per_bar : float
23
+ beats_per_minute : float
24
+ frame : int
25
+ frame_rate : int
26
+ frame_time : float
27
+ next_time : float
28
+ padding : _CDataBase # <cdata 'int32_t[7]'>
29
+ tick : int
30
+ ticks_per_beat : float
31
+ unique_1 : int
32
+ unique_2 : int
33
+ usecs : int
34
+ valid : int
35
+ video_offset : int
10
36
11
37
class _CBufferType :
12
38
@overload
@@ -100,9 +126,9 @@ class Client:
100
126
@transport_frame .setter
101
127
def transport_frame (self , frame : int ) -> None : ...
102
128
def transport_locate (self , frame : int ) -> None : ...
103
- def transport_query (self ) -> tuple [TransportState , dict [str , Any ]]: ...
129
+ def transport_query (self ) -> tuple [TransportState , dict [str , Any ]]: ... # Anyof[int, float, _CDataBase]
104
130
def transport_query_struct (self ) -> tuple [TransportState , _JackPositionT ]: ...
105
- def transport_reposition_struct (self , position : _JackPositionT ) -> None : ... # TODO
131
+ def transport_reposition_struct (self , position : _JackPositionT ) -> None : ...
106
132
def set_sync_timeout (self , timeout : int ) -> None : ...
107
133
def set_freewheel (self , onoff : bool ) -> None : ...
108
134
def set_shutdown_callback (self , callback : Callable [[Status , str ], object ]) -> None : ...
@@ -149,7 +175,8 @@ class Client:
149
175
def remove_all_properties (self ) -> None : ...
150
176
151
177
class Port :
152
- def __init__ (self , port_ptr : Any , client : Client ) -> None : ...
178
+ # <cdata 'struct _jack_port *'>
179
+ def __init__ (self , port_ptr : _CDataBase , client : Client ) -> None : ...
153
180
def __eq__ (self , other : object ) -> bool : ...
154
181
def __ne__ (self , other : object ) -> bool : ...
155
182
@property
@@ -196,12 +223,14 @@ class OwnPort(Port):
196
223
def disconnect (self , other : str | Port | None = ...) -> None : ...
197
224
def unregister (self ) -> None : ...
198
225
def get_buffer (self ) -> _CBufferType : ...
199
- def get_array (self ) -> _NDArray : ...
226
+ def get_array (self ) -> NDArray [ numpy . float32 ] : ...
200
227
201
228
class OwnMidiPort (MidiPort , OwnPort ):
202
- def __init__ (self , * args : Any , ** kwargs : Any ) -> None : ...
203
- def get_buffer (self ) -> _CBufferType : ...
204
- def get_array (self ) -> _NDArray : ...
229
+ def __init__ (self , port_ptr : _CDataBase , client : Client ) -> None : ...
230
+ # The implementation raises NotImplementedError, but this is not an abstract class.
231
+ # `get_buffer()` and `get_array()` are disabled for OwnMidiPort
232
+ def get_buffer (self ) -> NoReturn : ...
233
+ def get_array (self ) -> NoReturn : ...
205
234
@property
206
235
def max_event_size (self ) -> int : ...
207
236
@property
@@ -212,7 +241,7 @@ class OwnMidiPort(MidiPort, OwnPort):
212
241
def reserve_midi_event (self , time : int , size : int ) -> _CBufferType : ...
213
242
214
243
class Ports :
215
- def __init__ (self , client : Client , porttype : Any , flag : Any ) -> None : ...
244
+ def __init__ (self , client : Client , porttype : str , flag : int ) -> None : ...
216
245
def __len__ (self ) -> int : ...
217
246
def __getitem__ (self , name : str ) -> Port : ...
218
247
def __iter__ (self ) -> Iterator [Port ]: ...
@@ -278,7 +307,7 @@ class CallbackExit(Exception): ...
278
307
def get_property (subject : int | str , key : str ) -> tuple [bytes , str ] | None : ...
279
308
def get_properties (subject : int | str ) -> dict [str , tuple [bytes , str ]]: ...
280
309
def get_all_properties () -> dict [str , dict [str , tuple [bytes , str ]]]: ...
281
- def position2dict (pos : _JackPositionT ) -> dict [str , Any ]: ...
310
+ def position2dict (pos : _JackPositionT ) -> dict [str , Any ]: ... # Anyof[int, float, _CDataBase]
282
311
def version () -> tuple [int , int , int , int ]: ...
283
312
def version_string () -> str : ...
284
313
def client_name_size () -> int : ...
0 commit comments