Skip to content

Commit 2dba432

Browse files
authored
Improve cffi (#13710)
1 parent 8d67718 commit 2dba432

9 files changed

+221
-208
lines changed

stubs/cffi/@tests/stubtest_allowlist.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# TODO: missing from stub
2-
cffi.__all__
3-
41
# added dynamically and not detected by stubtest
52
cffi.(api.)?FFI.CData
63
cffi.(api.)?FFI.CType

stubs/cffi/cffi/__init__.pyi

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
from typing import Final
2+
13
from .api import FFI as FFI
24
from .error import (
35
CDefError as CDefError,
46
FFIError as FFIError,
7+
PkgConfigError as PkgConfigError,
58
VerificationError as VerificationError,
69
VerificationMissing as VerificationMissing,
710
)
811

9-
__version__: str
10-
__version_info__: tuple[int, int, int]
11-
__version_verifier_modules__: str
12+
__all__ = ["FFI", "VerificationError", "VerificationMissing", "CDefError", "FFIError"]
13+
__version__: Final[str]
14+
__version_info__: Final[tuple[int, int, int]]
15+
__version_verifier_modules__: Final[str]

stubs/cffi/cffi/backend_ctypes.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Callable
23

34
unicode = str
45
long = int
56
xrange = range
6-
bytechr: Incomplete
7+
bytechr: Callable[[float], bytes]
78

89
class CTypesType(type): ...
910

stubs/cffi/cffi/cffi_opcode.pyi

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,92 @@
1-
from _typeshed import Incomplete
1+
from typing import Final
22

33
class CffiOp:
4-
op: Incomplete
5-
arg: Incomplete
6-
def __init__(self, op, arg) -> None: ...
7-
def as_c_expr(self): ...
8-
def as_python_bytes(self): ...
4+
op: int | None
5+
arg: str | None
6+
def __init__(self, op: int | None, arg: str | None) -> None: ...
7+
def as_c_expr(self) -> str: ...
8+
def as_python_bytes(self) -> str: ...
99

10-
def format_four_bytes(num): ...
10+
def format_four_bytes(num: int) -> str: ...
1111

12-
OP_PRIMITIVE: int
13-
OP_POINTER: int
14-
OP_ARRAY: int
15-
OP_OPEN_ARRAY: int
16-
OP_STRUCT_UNION: int
17-
OP_ENUM: int
18-
OP_FUNCTION: int
19-
OP_FUNCTION_END: int
20-
OP_NOOP: int
21-
OP_BITFIELD: int
22-
OP_TYPENAME: int
23-
OP_CPYTHON_BLTN_V: int
24-
OP_CPYTHON_BLTN_N: int
25-
OP_CPYTHON_BLTN_O: int
26-
OP_CONSTANT: int
27-
OP_CONSTANT_INT: int
28-
OP_GLOBAL_VAR: int
29-
OP_DLOPEN_FUNC: int
30-
OP_DLOPEN_CONST: int
31-
OP_GLOBAL_VAR_F: int
32-
OP_EXTERN_PYTHON: int
33-
PRIM_VOID: int
34-
PRIM_BOOL: int
35-
PRIM_CHAR: int
36-
PRIM_SCHAR: int
37-
PRIM_UCHAR: int
38-
PRIM_SHORT: int
39-
PRIM_USHORT: int
40-
PRIM_INT: int
41-
PRIM_UINT: int
42-
PRIM_LONG: int
43-
PRIM_ULONG: int
44-
PRIM_LONGLONG: int
45-
PRIM_ULONGLONG: int
46-
PRIM_FLOAT: int
47-
PRIM_DOUBLE: int
48-
PRIM_LONGDOUBLE: int
49-
PRIM_WCHAR: int
50-
PRIM_INT8: int
51-
PRIM_UINT8: int
52-
PRIM_INT16: int
53-
PRIM_UINT16: int
54-
PRIM_INT32: int
55-
PRIM_UINT32: int
56-
PRIM_INT64: int
57-
PRIM_UINT64: int
58-
PRIM_INTPTR: int
59-
PRIM_UINTPTR: int
60-
PRIM_PTRDIFF: int
61-
PRIM_SIZE: int
62-
PRIM_SSIZE: int
63-
PRIM_INT_LEAST8: int
64-
PRIM_UINT_LEAST8: int
65-
PRIM_INT_LEAST16: int
66-
PRIM_UINT_LEAST16: int
67-
PRIM_INT_LEAST32: int
68-
PRIM_UINT_LEAST32: int
69-
PRIM_INT_LEAST64: int
70-
PRIM_UINT_LEAST64: int
71-
PRIM_INT_FAST8: int
72-
PRIM_UINT_FAST8: int
73-
PRIM_INT_FAST16: int
74-
PRIM_UINT_FAST16: int
75-
PRIM_INT_FAST32: int
76-
PRIM_UINT_FAST32: int
77-
PRIM_INT_FAST64: int
78-
PRIM_UINT_FAST64: int
79-
PRIM_INTMAX: int
80-
PRIM_UINTMAX: int
81-
PRIM_FLOATCOMPLEX: int
82-
PRIM_DOUBLECOMPLEX: int
83-
PRIM_CHAR16: int
84-
PRIM_CHAR32: int
85-
PRIMITIVE_TO_INDEX: Incomplete
86-
F_UNION: int
87-
F_CHECK_FIELDS: int
88-
F_PACKED: int
89-
F_EXTERNAL: int
90-
F_OPAQUE: int
91-
G_FLAGS: Incomplete
92-
CLASS_NAME: Incomplete
12+
OP_PRIMITIVE: Final = 1
13+
OP_POINTER: Final = 3
14+
OP_ARRAY: Final = 5
15+
OP_OPEN_ARRAY: Final = 7
16+
OP_STRUCT_UNION: Final = 9
17+
OP_ENUM: Final = 11
18+
OP_FUNCTION: Final = 13
19+
OP_FUNCTION_END: Final = 15
20+
OP_NOOP: Final = 17
21+
OP_BITFIELD: Final = 19
22+
OP_TYPENAME: Final = 21
23+
OP_CPYTHON_BLTN_V: Final = 23
24+
OP_CPYTHON_BLTN_N: Final = 25
25+
OP_CPYTHON_BLTN_O: Final = 27
26+
OP_CONSTANT: Final = 29
27+
OP_CONSTANT_INT: Final = 31
28+
OP_GLOBAL_VAR: Final = 33
29+
OP_DLOPEN_FUNC: Final = 35
30+
OP_DLOPEN_CONST: Final = 37
31+
OP_GLOBAL_VAR_F: Final = 39
32+
OP_EXTERN_PYTHON: Final = 41
33+
PRIM_VOID: Final = 0
34+
PRIM_BOOL: Final = 1
35+
PRIM_CHAR: Final = 2
36+
PRIM_SCHAR: Final = 3
37+
PRIM_UCHAR: Final = 4
38+
PRIM_SHORT: Final = 5
39+
PRIM_USHORT: Final = 6
40+
PRIM_INT: Final = 7
41+
PRIM_UINT: Final = 8
42+
PRIM_LONG: Final = 9
43+
PRIM_ULONG: Final = 10
44+
PRIM_LONGLONG: Final = 11
45+
PRIM_ULONGLONG: Final = 12
46+
PRIM_FLOAT: Final = 13
47+
PRIM_DOUBLE: Final = 14
48+
PRIM_LONGDOUBLE: Final = 15
49+
PRIM_WCHAR: Final = 16
50+
PRIM_INT8: Final = 17
51+
PRIM_UINT8: Final = 18
52+
PRIM_INT16: Final = 19
53+
PRIM_UINT16: Final = 20
54+
PRIM_INT32: Final = 21
55+
PRIM_UINT32: Final = 22
56+
PRIM_INT64: Final = 23
57+
PRIM_UINT64: Final = 24
58+
PRIM_INTPTR: Final = 25
59+
PRIM_UINTPTR: Final = 26
60+
PRIM_PTRDIFF: Final = 27
61+
PRIM_SIZE: Final = 28
62+
PRIM_SSIZE: Final = 29
63+
PRIM_INT_LEAST8: Final = 30
64+
PRIM_UINT_LEAST8: Final = 31
65+
PRIM_INT_LEAST16: Final = 32
66+
PRIM_UINT_LEAST16: Final = 33
67+
PRIM_INT_LEAST32: Final = 34
68+
PRIM_UINT_LEAST32: Final = 35
69+
PRIM_INT_LEAST64: Final = 36
70+
PRIM_UINT_LEAST64: Final = 37
71+
PRIM_INT_FAST8: Final = 38
72+
PRIM_UINT_FAST8: Final = 39
73+
PRIM_INT_FAST16: Final = 40
74+
PRIM_UINT_FAST16: Final = 41
75+
PRIM_INT_FAST32: Final = 42
76+
PRIM_UINT_FAST32: Final = 43
77+
PRIM_INT_FAST64: Final = 44
78+
PRIM_UINT_FAST64: Final = 45
79+
PRIM_INTMAX: Final = 46
80+
PRIM_UINTMAX: Final = 47
81+
PRIM_FLOATCOMPLEX: Final = 48
82+
PRIM_DOUBLECOMPLEX: Final = 49
83+
PRIM_CHAR16: Final = 50
84+
PRIM_CHAR32: Final = 51
85+
PRIMITIVE_TO_INDEX: Final[dict[str, int]]
86+
F_UNION: Final = 1
87+
F_CHECK_FIELDS: Final = 2
88+
F_PACKED: Final = 4
89+
F_EXTERNAL: Final = 8
90+
F_OPAQUE: Final = 16
91+
G_FLAGS: Final[dict[bytes, bytes]]
92+
CLASS_NAME: Final[dict[int, str]]

stubs/cffi/cffi/ffiplatform.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
from _typeshed import Incomplete
1+
from _typeshed import Incomplete, StrOrBytesPath
2+
from typing import Any, Final
23

3-
LIST_OF_FILE_NAMES: Incomplete
4+
LIST_OF_FILE_NAMES: Final[list[str]]
45

56
def get_extension(srcfilename, modname, sources=(), **kwds): ...
67
def compile(tmpdir, ext, compiler_verbose: int = 0, debug: Incomplete | None = None): ...
7-
def maybe_relative_path(path): ...
8+
def maybe_relative_path(path: StrOrBytesPath) -> StrOrBytesPath | str: ...
89

910
int_or_long = int
1011

11-
def flatten(x): ...
12+
def flatten(x: int | str | list[Any] | tuple[Any] | dict[Any, Any]) -> str: ...

0 commit comments

Comments
 (0)