Skip to content

Commit

Permalink
👽️ _lib: fix new stubtest errors (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenham authored Dec 16, 2024
2 parents 5cefe76 + a87bfd8 commit 6baddd2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .mypyignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
scipy\.(\w+\.)?_typing

# git submodules
scipy\._lib\.(array_api_compat|cobyqa).*
scipy\._lib\.(array_api_compat|array_api_extra|cobyqa).*

# private bundled pypocketfft library
scipy\.fft\._pocketfft\..*
Expand Down
26 changes: 0 additions & 26 deletions .mypyignore-todo
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
scipy\._lib\.array_api_extra
scipy\._lib\._array_api\.__all__
scipy\._lib\._array_api\.SCIPY_(ARRAY_API|DEVICE)
scipy\._lib\._array_api\.assert_(array_)?almost_equal
scipy\._lib\._array_api\.get_xp_devices
scipy\._lib\._array_api\.is_complex
scipy\._lib\._array_api\.is_(array_api_strict|cupy|jax|numpy|torch)
scipy\._lib\._array_api\.scipy_namespace_for
scipy\._lib\._array_api\.xp_assert_(close|equal|less)
scipy\._lib\._array_api\.xp_copy(sign)?
scipy\._lib\._array_api\.(xp_)?device
scipy\._lib\._array_api\.xp_ravel
scipy\._lib\._array_api\.xp_real
scipy\._lib\._array_api\.xp_sign
scipy\._lib\._array_api\.(xp_)?size
scipy\._lib\._array_api\.xp_moveaxis_to_end
scipy\._lib\._array_api\.xp_take_along_axis
scipy\._lib\._array_api\.xp_unsupported_param_msg
scipy\._lib\._array_api\.xp_vector_norm
scipy\._lib\._docscrape\.(ClassDoc|FunctionDoc|NumpyDocString)\.__init__
scipy\._lib\._docscrape\.ObjDoc
scipy\._lib\._docscrape\.get_doc_object
scipy\._lib\._docscrape\.header
scipy\._lib\._docscrape\.indent
scipy\._lib\._util\.(Generator|Seed)Type

scipy\.cluster\.hierarchy\.ClusterNode\.__init__
scipy\.cluster\.vq\.kmeans2?

Expand Down
76 changes: 0 additions & 76 deletions scipy-stubs/_lib/_array_api.pyi

This file was deleted.

29 changes: 22 additions & 7 deletions scipy-stubs/_lib/_docscrape.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ from typing_extensions import TypeVar, override
import optype as op

_FT = TypeVar("_FT", bound=Callable[..., object], default=Callable[..., object])
_SectionValue: TypeAlias = str | list[str] | dict[str, list[str]]
_SectionValue: TypeAlias = str | list[str] | Mapping[str, list[str]]

###

class ParseError(Exception): ...

Expand All @@ -29,8 +31,9 @@ class Reader:

class NumpyDocString(Mapping[str, _SectionValue]):
empty_description: ClassVar[str] = ".."
sections: ClassVar[dict[str, _SectionValue]]
def __init__(self, /, docstring: str, config: dict[str, object] = {}) -> None: ...
sections: ClassVar[Mapping[str, _SectionValue]]

def __init__(self, /, docstring: str, config: Mapping[str, object] | None = None) -> None: ...
@override
def __str__(self, /, func_role: str = "") -> str: ...
@override
Expand All @@ -48,7 +51,7 @@ class FunctionDoc(NumpyDocString, Generic[_FT]):
func: _FT,
role: Literal["func", "meth"] = "func",
doc: str | None = None,
config: dict[str, object] = {},
config: Mapping[str, object] | None = None,
) -> None: ...
@override
def __str__(self, /) -> str: ... # type: ignore[override] # noqa: PYI029 # pyright: ignore[reportIncompatibleMethodOverride]
Expand All @@ -57,6 +60,7 @@ class FunctionDoc(NumpyDocString, Generic[_FT]):
class ClassDoc(NumpyDocString):
extra_public_methods: ClassVar[Sequence[str]]
show_inherited_members: Final[bool]

@property
def methods(self, /) -> list[str]: ...
@property
Expand All @@ -69,10 +73,21 @@ class ClassDoc(NumpyDocString):
modulename: str = "",
# NOTE: we can't set this to `type[FunctionDoc]` because of a mypy bug
func_doc: type = ...,
config: dict[str, object] = {},
config: Mapping[str, object] | None = None,
) -> None: ...

class ObjDoc(NumpyDocString):
def __init__(self, /, obj: object, doc: str | None = None, config: Mapping[str, object] | None = None) -> None: ...

def strip_blank_lines(l: list[str]) -> list[str]: ...
def indent(str: str | None, indent: int = 4) -> str: ...
def dedent_lines(lines: op.CanIter[op.CanIterSelf[str]]) -> str: ...
def header(text: str, style: str = "-") -> str: ...
def get_doc_object(
obj: object,
what: str | None = None,
doc: str | None = None,
config: Mapping[str, object] | None = None,
# NOTE: due to a mypy bug, these can't be made any more specific
class_doc: type = ...,
func_doc: type = ...,
obj_doc: type = ...,
) -> NumpyDocString: ...
5 changes: 5 additions & 0 deletions scipy-stubs/_lib/_util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ copy_if_needed: Final[bool | None] = ...
IntNumber: TypeAlias = int | np.integer[Any]
DecimalNumber: TypeAlias = float | np.floating[Any] | np.integer[Any]

_RNG: TypeAlias = np.random.Generator | np.random.RandomState
SeedType: TypeAlias = IntNumber | _RNG | None
# NOTE: This is actually a exported at runtime :(
GeneratorType = TypeVar("GeneratorType", bound=_RNG) # noqa: PYI001

class ComplexWarning(RuntimeWarning): ...
class VisibleDeprecationWarning(UserWarning): ...
class DTypePromotionError(TypeError): ...
Expand Down

0 comments on commit 6baddd2

Please sign in to comment.