Skip to content

Commit 695cf71

Browse files
committed
TYP: Stub numpy.__config__, add missing param to numpy.show_config
1 parent 6f84f54 commit 695cf71

File tree

3 files changed

+99
-2
lines changed

3 files changed

+99
-2
lines changed

numpy/__config__.pyi

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
from enum import Enum
2+
from types import ModuleType
3+
from typing import Final, Literal as L, TypedDict, overload, type_check_only
4+
from typing_extensions import NotRequired
5+
6+
_CompilerConfigDictValue = TypedDict(
7+
"_CompilerConfigDictValue",
8+
{
9+
"name": str,
10+
"linker": str,
11+
"version": str,
12+
"commands": str,
13+
"args": str,
14+
"linker args": str,
15+
},
16+
)
17+
_CompilerConfigDict = TypedDict(
18+
"_CompilerConfigDict",
19+
{
20+
"c": _CompilerConfigDictValue,
21+
"cython": _CompilerConfigDictValue,
22+
"c++": _CompilerConfigDictValue,
23+
},
24+
)
25+
_MachineInformationDict = TypedDict(
26+
"_MachineInformationDict",
27+
{
28+
"host":_MachineInformationDictValue,
29+
"build": _MachineInformationDictValue,
30+
"cross-compiled": NotRequired[L[True]],
31+
},
32+
)
33+
34+
@type_check_only
35+
class _MachineInformationDictValue(TypedDict):
36+
cpu: str
37+
family: str
38+
endian: L["little", "big"]
39+
system: str
40+
41+
_BuildDependenciesDictValue = TypedDict(
42+
"_BuildDependenciesDictValue",
43+
{
44+
"name": str,
45+
"found": NotRequired[L[True]],
46+
"version": str,
47+
"include directory": str,
48+
"lib directory": str,
49+
"openblas configuration": str,
50+
"pc file directory": str,
51+
},
52+
)
53+
54+
class _BuildDependenciesDict(TypedDict):
55+
blas: _BuildDependenciesDictValue
56+
lapack: _BuildDependenciesDictValue
57+
58+
class _PythonInformationDict(TypedDict):
59+
path: str
60+
version: str
61+
62+
_SIMDExtensionsDict = TypedDict(
63+
"_SIMDExtensionsDict",
64+
{
65+
"baseline": list[str],
66+
"found": list[str],
67+
"not found": list[str],
68+
},
69+
)
70+
71+
_ConfigDict = TypedDict(
72+
"_ConfigDict",
73+
{
74+
"Compilers": _CompilerConfigDict,
75+
"Machine Information": _MachineInformationDict,
76+
"Build Dependencies": _BuildDependenciesDict,
77+
"Python Information": _PythonInformationDict,
78+
"SIMD Extensions": _SIMDExtensionsDict,
79+
},
80+
)
81+
82+
###
83+
84+
__all__ = ["show"]
85+
86+
CONFIG: Final[_ConfigDict] = ...
87+
88+
class DisplayModes(Enum):
89+
stdout = "stdout"
90+
dicts = "dicts"
91+
92+
def _check_pyyaml() -> ModuleType: ...
93+
94+
@overload
95+
def show(mode: L["stdout"] = "stdout") -> None: ...
96+
@overload
97+
def show(mode: L["dicts"]) -> _ConfigDict: ...

numpy/__init__.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ from fractions import Fraction
1212
from uuid import UUID
1313

1414
import numpy as np
15+
from numpy.__config__ import show as show_config
1516
from numpy._pytesttester import PytestTester
1617
from numpy._core._internal import _ctypes
1718

@@ -4780,5 +4781,3 @@ def from_dlpack(
47804781
device: L["cpu"] | None = None,
47814782
copy: builtins.bool | None = None,
47824783
) -> NDArray[number[Any] | np.bool]: ...
4783-
4784-
def show_config() -> None: ...

numpy/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ python_sources = [
271271
'__init__.pxd',
272272
'__init__.py',
273273
'__init__.pyi',
274+
'__config__.pyi',
274275
'_array_api_info.py',
275276
'_array_api_info.pyi',
276277
'_configtool.py',

0 commit comments

Comments
 (0)