Skip to content

Commit e315276

Browse files
committed
fix stubtest errors
1 parent b133cd0 commit e315276

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

threadpoolctl/__init__.pyi

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ from collections.abc import Iterable
66
from contextlib import ContextDecorator
77
from typing import Any, ClassVar, Final, Literal, final, type_check_only
88

9-
from _typeshed import Incomplete
10-
from typing_extensions import Never, Self, TypeAlias, TypedDict, override
9+
from typing_extensions import Never, Self, TypeAlias, TypedDict, TypeVar, override
10+
11+
_CDataT = TypeVar("_CDataT", bound=ctypes._CData) # pyright: ignore[reportPrivateUsage]
12+
_PythonT = TypeVar("_PythonT") # pyright: ignore[reportPrivateUsage]
13+
_CField: TypeAlias = ctypes._CField[_CDataT, _PythonT, _CDataT | _PythonT] # pyright: ignore[reportPrivateUsage]
1114

1215
_ThreadingLayerOpenBLAS: TypeAlias = _ThreadingLayerBLIS | Literal["unknown"]
1316
_ThreadingLayerBLIS: TypeAlias = Literal["openmp", "pthreads", "disabled"]
@@ -34,7 +37,7 @@ class _InfoDict(TypedDict):
3437

3538
@final
3639
@type_check_only
37-
class _OpenMPSequentialBlasDict(TypedDict):
40+
class _OMPBlasDict(TypedDict):
3841
limits: Literal[1] | None
3942
user_api: Literal["blas"] | None
4043

@@ -49,14 +52,19 @@ __all__ = [
4952
"threadpool_limits",
5053
]
5154

52-
_SYSTEM_UINT: Final[type[ctypes.c_uint32 | ctypes.c_uint64]] = ...
55+
_SYSTEM_UINT: Final[type[ctypes.c_size_t]] = ...
5356
_SYSTEM_UINT_HALF: Final[type[ctypes.c_uint16 | ctypes.c_uint32]] = ...
5457
_RTLD_NOLOAD: Final[int] = ...
5558

5659
@final
5760
class _dl_phdr_info(ctypes.Structure):
5861
_fields_: ClassVar = ...
5962

63+
dlpi_addr: _CField[ctypes.c_size_t, int]
64+
dlpi_name: _CField[ctypes.c_char_p, bytes | None]
65+
dlpi_phdr: _CField[ctypes.c_void_p, int | None]
66+
dlpi_phnum: _CField[ctypes.c_uint16 | ctypes.c_uint32, int]
67+
6068
class LibController(abc.ABC):
6169
user_api: ClassVar[str] # abstract
6270
internal_api: ClassVar[str] # abstract
@@ -90,7 +98,7 @@ class LibController(abc.ABC):
9098
@abc.abstractmethod
9199
def get_version(self) -> str | None: ...
92100
def _find_affixes(self) -> tuple[str, str]: ...
93-
def _get_symbol(self, /, name: str) -> Incomplete | None: ...
101+
def _get_symbol(self, /, name: str) -> Any | None: ...
94102

95103
class OpenBLASController(LibController):
96104
user_api: ClassVar[str] = "blas"
@@ -149,7 +157,7 @@ class FlexiBLASController(LibController):
149157
def set_num_threads(self, /, num_threads: int) -> None: ...
150158
@override
151159
def get_version(self) -> str | None: ...
152-
def _get_backend_list(self, loaded: bool = False) -> list[str]: ...
160+
def _get_backend_list(self, /, loaded: bool = False) -> list[str]: ...
153161
def _get_current_backend(self) -> str: ...
154162
def switch_backend(self, /, backend: str) -> None: ...
155163

@@ -251,10 +259,8 @@ class ThreadpoolController:
251259
@classmethod
252260
def _from_controllers(cls, lib_controllers: list[LibController]) -> Self: ...
253261
def info(self) -> list[_InfoDict]: ...
254-
def select(self, **kwargs: Incomplete) -> Self: ...
255-
def _get_params_for_sequential_blas_under_openmp(
256-
self,
257-
) -> _OpenMPSequentialBlasDict: ...
262+
def select(self, /, **kwargs: object) -> Self: ...
263+
def _get_params_for_sequential_blas_under_openmp(self) -> _OMPBlasDict: ...
258264
def limit(
259265
self, /, *, limits: _ToLimits | None = None, user_api: list[str] | None = None
260266
) -> _ThreadpoolLimiter: ...
@@ -263,9 +269,7 @@ class ThreadpoolController:
263269
) -> _ThreadpoolLimiter: ...
264270
def __len__(self) -> int: ...
265271
def _load_libraries(self) -> None: ...
266-
def _find_libraries_with_dl_iterate_phdr(
267-
self,
268-
) -> list[Never] | Literal[0] | None: ...
272+
def _find_libraries_with_dl_iterate_phdr(self) -> list[Never] | int | None: ...
269273
def _find_libraries_with_dyld(self) -> list[Never] | None: ...
270274
def _find_libraries_with_enum_process_module_ex(self) -> None: ...
271275
def _find_libraries_pyodide(self) -> None: ...

0 commit comments

Comments
 (0)