Skip to content

Commit 180d910

Browse files
authored
Merge pull request #10716 from jorenham/typing/experimental.jitclass
`jitclass` type stubs
2 parents 1979f73 + facb65a commit 180d910

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎maint/stubtest/allowlist.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ numba\.core\.untyped_passes\..*
2525
numba\.core\.utils\..*
2626
numba\.cpython\..*
2727
numba\.cuda\..*
28-
numba\.experimental\..*
28+
numba\.experimental\.structref
2929
numba\.misc\.POST
3030
numba\.misc\.appdirs\..*
3131
numba\.misc\.coverage_support\..*
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from collections.abc import Mapping, Sequence
2+
from typing import Protocol, TypeAlias, overload, type_check_only
3+
4+
from typing_extensions import TypeVar
5+
6+
from numba.core import types
7+
8+
###
9+
10+
_ToSpec: TypeAlias = Mapping[str, types.Type] | Sequence[tuple[str, types.Type]]
11+
12+
_ClsT = TypeVar("_ClsT", bound=type)
13+
14+
@type_check_only
15+
class _Wrap(Protocol):
16+
def __call__(self, cls: _ClsT) -> _ClsT: ...
17+
18+
###
19+
20+
@overload
21+
def jitclass(cls_or_spec: None = None, spec: _ToSpec | None = None) -> _Wrap: ...
22+
@overload
23+
def jitclass(cls_or_spec: _ToSpec, spec: None = None) -> _Wrap: ...
24+
@overload
25+
def jitclass(cls_or_spec: _ClsT, spec: _ToSpec | None = None) -> _ClsT: ...

0 commit comments

Comments
 (0)