From ab755f0bb7cfe0d4a569ddf93baff08e94b1a489 Mon Sep 17 00:00:00 2001 From: jorenham Date: Sat, 21 Dec 2024 16:34:37 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20more=20precise=20`=5F=5Fconfig=5F?= =?UTF-8?q?=5F`=20and=20`=5F=5Finit=5F=5F`=20annotations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scipy-stubs/__config__.pyi | 106 +++++++++++++++++++++++++++++++++---- scipy-stubs/__init__.pyi | 56 ++++++++++---------- 2 files changed, 124 insertions(+), 38 deletions(-) diff --git a/scipy-stubs/__config__.pyi b/scipy-stubs/__config__.pyi index 095bbf0e..1b29fae4 100644 --- a/scipy-stubs/__config__.pyi +++ b/scipy-stubs/__config__.pyi @@ -2,30 +2,116 @@ # It contains system_info results at the time of building this package. from enum import Enum from types import ModuleType -from typing import Final, Literal, TypedDict, overload +from typing import Final, Literal, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import NotRequired __all__ = ["show"] +_ConfigCompilerDict = TypedDict( + "_ConfigCompilerDict", + { + "name": str, + "version": str, + "linker": str, + "commands": str, + "args": NotRequired[str], + "linker args": NotRequired[str], + }, +) +_ConfigCompilerFortranDict = TypedDict( + "_ConfigCompilerFortranDict", + { + "version": str, + "include directory": str, + }, +) +_ConfigCompilersDict = TypedDict( + "_ConfigCompilersDict", + { + "c": _ConfigCompilerDict, + "cython": _ConfigCompilerDict, + "c++": _ConfigCompilerDict, + "fortran": _ConfigCompilerDict, + "pythran": _ConfigCompilerFortranDict, + }, +) + +@type_check_only +class _ConfigMachineInformationValueDict(TypedDict): + cpu: str + family: str + endian: Literal["little", "big"] + system: str + +_ConfigMachineInformationDict = TypedDict( + "_ConfigMachineInformationDict", + { + "host": _ConfigMachineInformationValueDict, + "build": _ConfigMachineInformationValueDict, + "cross-compiled": bool, + }, +) +_ConfigBuildDependencyDict = TypedDict( + "_ConfigBuildDependencyDict", + { + "name": str, + "found": bool, + "version": str, + "detection method": str, + "include directory": str, + "lib directory": str, + "openblas configuration": str, + "pc file directory": str, + }, +) +_ConfigBuildDependencyPybind11Dict = TypedDict( + "_ConfigBuildDependencyPybind11Dict", + { + "name": Literal["pybind11"], + "version": str, + "detection method": NotRequired[str], + "include directory": str, + }, +) + +@type_check_only +class _ConfigBuildDependenciesDict(TypedDict): + blas: _ConfigBuildDependencyDict + lapack: _ConfigBuildDependencyDict + pybind11: _ConfigBuildDependencyPybind11Dict + +@type_check_only +class _ConfigPythonInformationDict(TypedDict): + path: str + version: Literal["3.10", "3.11", "3.12", "3.13", "3.14"] + _ConfigDict = TypedDict( "_ConfigDict", { - "Compilers": dict[str, dict[str, str]], - "Machine Information": dict[str, dict[str, str] | bool], - "Build Dependencies": dict[str, dict[str, str | bool]], - "Python Information": dict[str, str], + "Compilers": _ConfigCompilersDict, + "Machine Information": _ConfigMachineInformationDict, + "Build Dependencies": _ConfigBuildDependenciesDict, + "Python Information": _ConfigPythonInformationDict, }, ) -_built_with_meson: Final[bool] +### + +_built_with_meson: Final[bool] = ... +CONFIG: Final[_ConfigDict] = ... class DisplayModes(Enum): stdout = "stdout" dicts = "dicts" -CONFIG: Final[_ConfigDict] - -def _check_pyyaml() -> ModuleType: ... +# @overload -def show(mode: Literal["stdout"] = "stdout") -> _ConfigDict: ... +def show(mode: Literal["stdout"] = "stdout") -> None: ... @overload def show(mode: Literal["dicts"]) -> _ConfigDict: ... + +# +_ConfigT = TypeVar("_ConfigT", bound=_ConfigDict) + +def _cleanup(d: _ConfigT) -> _ConfigT: ... +def _check_pyyaml() -> ModuleType: ... diff --git a/scipy-stubs/__init__.pyi b/scipy-stubs/__init__.pyi index 35f54aab..44feca98 100644 --- a/scipy-stubs/__init__.pyi +++ b/scipy-stubs/__init__.pyi @@ -1,6 +1,5 @@ from collections.abc import Sequence -from typing import Final, Literal -from typing_extensions import LiteralString +from typing import Final, Literal, TypeAlias from numpy import __version__ as __numpy_version__ # noqa: ICN003 from . import ( @@ -53,32 +52,33 @@ __all__ = [ "stats", "test", ] -np_minversion: Final[LiteralString] -np_maxversion: Final[LiteralString] -test: Final[PytestTester] +### -submodules: Final[ - Sequence[ - Literal[ - "cluster", - "constants", - "datasets", - "differentiate", - "fft", - "fftpack", - "integrate", - "interpolate", - "io", - "linalg", - "ndimage", - "odr", - "optimize", - "signal", - "sparse", - "spatial", - "special", - "stats", - ] - ] +_SubModule: TypeAlias = Literal[ + "cluster", + "constants", + "datasets", + "differentiate", + "fft", + "fftpack", + "integrate", + "interpolate", + "io", + "linalg", + "ndimage", + "odr", + "optimize", + "signal", + "sparse", + "spatial", + "special", + "stats", ] + +### + +np_minversion: Final = "1.23.5" # undocumented +np_maxversion: Final = "2.5.0" # undocumented +test: Final[PytestTester] = ... # undocumented +submodules: Final[Sequence[_SubModule]] = ... # undocumented