Skip to content

Commit 2b748f5

Browse files
committed
♻️ sparse: return Any from the deprecated module functions
1 parent bc10609 commit 2b748f5

File tree

12 files changed

+146
-155
lines changed

12 files changed

+146
-155
lines changed

scipy-stubs/sparse/base.pyi

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
# ruff: noqa: ANN401
12
# This module is not meant for public use and will be removed in SciPy v2.0.0.
2-
from typing import Final
3+
4+
from typing import Any, Final
35
from typing_extensions import deprecated
46

57
from . import _base, _matrix
@@ -21,7 +23,7 @@ __all__ = [
2123
"validateaxis",
2224
]
2325

24-
MAXPRINT: Final[int]
26+
MAXPRINT: Final[int] = ...
2527

2628
@deprecated("will be removed in SciPy v2.0.0")
2729
class SparseWarning(_base.SparseWarning): ...
@@ -36,22 +38,22 @@ class SparseEfficiencyWarning(_base.SparseEfficiencyWarning): ...
3638
class spmatrix(_matrix.spmatrix): ...
3739

3840
@deprecated("will be removed in SciPy v2.0.0")
39-
def issparse(x: object) -> object: ...
41+
def issparse(x: object) -> bool: ...
4042
@deprecated("will be removed in SciPy v2.0.0")
41-
def isspmatrix(x: object) -> object: ...
43+
def isspmatrix(x: object) -> bool: ...
4244

4345
# sputils
4446
@deprecated("will be removed in SciPy v2.0.0")
45-
def check_shape(args: object, current_shape: object = ..., *, allow_nd: object = ...) -> object: ...
47+
def check_shape(args: object, current_shape: object = ..., *, allow_nd: object = ...) -> Any: ...
4648
@deprecated("will be removed in SciPy v2.0.0")
47-
def check_reshape_kwargs(kwargs: object) -> object: ...
49+
def check_reshape_kwargs(kwargs: object) -> Any: ...
4850
@deprecated("will be removed in SciPy v2.0.0")
4951
def validateaxis(axis: object) -> None: ...
5052
@deprecated("will be removed in SciPy v2.0.0")
51-
def isdense(x: object) -> object: ...
53+
def isdense(x: object) -> Any: ...
5254
@deprecated("will be removed in SciPy v2.0.0")
53-
def isscalarlike(x: object) -> object: ...
55+
def isscalarlike(x: object) -> Any: ...
5456
@deprecated("will be removed in SciPy v2.0.0")
55-
def get_sum_dtype(dtype: object) -> object: ...
57+
def get_sum_dtype(dtype: object) -> Any: ...
5658
@deprecated("will be removed in SciPy v2.0.0")
57-
def asmatrix(data: object, dtype: object = ...) -> object: ...
59+
def asmatrix(data: object, dtype: object = ...) -> Any: ...

scipy-stubs/sparse/bsr.pyi

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# ruff: noqa: ANN401
12
# This module is not meant for public use and will be removed in SciPy v2.0.0.
2-
import sys
3+
4+
from warnings import warn
5+
from typing import Any
36
from typing_extensions import deprecated
47

58
from . import _bsr, _matrix
@@ -31,46 +34,32 @@ class spmatrix(_matrix.spmatrix): ...
3134
class bsr_matrix(_bsr.bsr_matrix): ...
3235

3336
@deprecated("will be removed in SciPy v2.0.0")
34-
def bsr_matmat(*args: object, **kwargs: object) -> object: ...
37+
def bsr_matmat(*args: object, **kwargs: object) -> Any: ...
3538
@deprecated("will be removed in SciPy v2.0.0")
36-
def bsr_matvec(*args: object, **kwargs: object) -> object: ...
39+
def bsr_matvec(*args: object, **kwargs: object) -> Any: ...
3740
@deprecated("will be removed in SciPy v2.0.0")
38-
def bsr_matvecs(*args: object, **kwargs: object) -> object: ...
41+
def bsr_matvecs(*args: object, **kwargs: object) -> Any: ...
3942
@deprecated("will be removed in SciPy v2.0.0")
40-
def bsr_sort_indices(*args: object, **kwargs: object) -> object: ...
43+
def bsr_sort_indices(*args: object, **kwargs: object) -> Any: ...
4144
@deprecated("will be removed in SciPy v2.0.0")
42-
def bsr_tocsr(*args: object, **kwargs: object) -> object: ...
45+
def bsr_tocsr(*args: object, **kwargs: object) -> Any: ...
4346
@deprecated("will be removed in SciPy v2.0.0")
44-
def bsr_transpose(*args: object, **kwargs: object) -> object: ...
47+
def bsr_transpose(*args: object, **kwargs: object) -> Any: ...
4548
@deprecated("will be removed in SciPy v2.0.0")
46-
def csr_matmat_maxnnz(*args: object, **kwargs: object) -> object: ...
49+
def csr_matmat_maxnnz(*args: object, **kwargs: object) -> Any: ...
4750
@deprecated("will be removed in SciPy v2.0.0")
48-
def isspmatrix_bsr(x: object) -> object: ...
49-
50-
if sys.version_info >= (3, 12):
51-
@deprecated("will be removed in SciPy v2.0.0")
52-
def warn(
53-
message: object,
54-
category: object = ...,
55-
stacklevel: object = ...,
56-
source: object = ...,
57-
*,
58-
skip_file_prefixes: object = ...,
59-
) -> None: ...
60-
else:
61-
@deprecated("will be removed in SciPy v2.0.0")
62-
def warn(message: object, category: object = ..., stacklevel: object = ..., source: object = ...) -> None: ...
51+
def isspmatrix_bsr(x: object) -> Any: ...
6352

6453
# sputils
6554
@deprecated("will be removed in SciPy v2.0.0")
66-
def upcast(*args: object) -> object: ...
55+
def upcast(*args: object) -> Any: ...
6756
@deprecated("will be removed in SciPy v2.0.0")
68-
def to_native(A: object) -> object: ...
57+
def to_native(A: object) -> Any: ...
6958
@deprecated("will be removed in SciPy v2.0.0")
70-
def getdtype(dtype: object, a: object = ..., default: object = ...) -> object: ...
59+
def getdtype(dtype: object, a: object = ..., default: object = ...) -> Any: ...
7160
@deprecated("will be removed in SciPy v2.0.0")
72-
def getdata(obj: object, dtype: object = ..., copy: object = ...) -> object: ...
61+
def getdata(obj: object, dtype: object = ..., copy: object = ...) -> Any: ...
7362
@deprecated("will be removed in SciPy v2.0.0")
74-
def isshape(x: object, nonneg: object = ..., *, allow_nd: object = ...) -> object: ...
63+
def isshape(x: object, nonneg: object = ..., *, allow_nd: object = ...) -> Any: ...
7564
@deprecated("will be removed in SciPy v2.0.0")
76-
def check_shape(args: object, current_shape: object = ..., *, allow_nd: object = ...) -> object: ...
65+
def check_shape(args: object, current_shape: object = ..., *, allow_nd: object = ...) -> Any: ...

scipy-stubs/sparse/compressed.pyi

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
# ruff: noqa: ANN401
12
# This module is not meant for public use and will be removed in SciPy v2.0.0.
3+
24
import operator
3-
import sys
5+
from warnings import warn
6+
from typing import Any
47
from typing_extensions import deprecated
58

69
from . import _base, _index
@@ -38,59 +41,45 @@ class SparseEfficiencyWarning(_base.SparseEfficiencyWarning): ...
3841
@deprecated("will be removed in SciPy v2.0.0")
3942
class IndexMixin(_index.IndexMixin): ...
4043

41-
if sys.version_info >= (3, 12):
42-
@deprecated("will be removed in SciPy v2.0.0")
43-
def warn(
44-
message: object,
45-
category: object = ...,
46-
stacklevel: object = ...,
47-
source: object = ...,
48-
*,
49-
skip_file_prefixes: object = ...,
50-
) -> None: ...
51-
else:
52-
@deprecated("will be removed in SciPy v2.0.0")
53-
def warn(message: object, category: object = ..., stacklevel: object = ..., source: object = ...) -> None: ...
54-
5544
@deprecated("will be removed in SciPy v2.0.0")
56-
def csr_column_index1(*args: object, **kwargs: object) -> object: ...
45+
def csr_column_index1(*args: object, **kwargs: object) -> Any: ...
5746
@deprecated("will be removed in SciPy v2.0.0")
58-
def csr_column_index2(*args: object, **kwargs: object) -> object: ...
47+
def csr_column_index2(*args: object, **kwargs: object) -> Any: ...
5948
@deprecated("will be removed in SciPy v2.0.0")
60-
def csr_row_index(*args: object, **kwargs: object) -> object: ...
49+
def csr_row_index(*args: object, **kwargs: object) -> Any: ...
6150
@deprecated("will be removed in SciPy v2.0.0")
62-
def csr_row_slice(*args: object, **kwargs: object) -> object: ...
51+
def csr_row_slice(*args: object, **kwargs: object) -> Any: ...
6352
@deprecated("will be removed in SciPy v2.0.0")
64-
def csr_sample_offsets(*args: object, **kwargs: object) -> object: ...
53+
def csr_sample_offsets(*args: object, **kwargs: object) -> Any: ...
6554
@deprecated("will be removed in SciPy v2.0.0")
66-
def csr_sample_values(*args: object, **kwargs: object) -> object: ...
55+
def csr_sample_values(*args: object, **kwargs: object) -> Any: ...
6756
@deprecated("will be removed in SciPy v2.0.0")
68-
def csr_todense(*args: object, **kwargs: object) -> object: ...
57+
def csr_todense(*args: object, **kwargs: object) -> Any: ...
6958
@deprecated("will be removed in SciPy v2.0.0")
70-
def get_csr_submatrix(*args: object, **kwargs: object) -> object: ...
59+
def get_csr_submatrix(*args: object, **kwargs: object) -> Any: ...
7160

7261
# sputils
7362
@deprecated("will be removed in SciPy v2.0.0")
74-
def upcast(*args: object) -> object: ...
63+
def upcast(*args: object) -> Any: ...
7564
@deprecated("will be removed in SciPy v2.0.0")
76-
def upcast_char(*args: object) -> object: ...
65+
def upcast_char(*args: object) -> Any: ...
7766
@deprecated("will be removed in SciPy v2.0.0")
78-
def to_native(A: object) -> object: ...
67+
def to_native(A: object) -> Any: ...
7968
@deprecated("will be removed in SciPy v2.0.0")
80-
def getdtype(dtype: object, a: object = ..., default: object = ...) -> object: ...
69+
def getdtype(dtype: object, a: object = ..., default: object = ...) -> Any: ...
8170
@deprecated("will be removed in SciPy v2.0.0")
82-
def isshape(x: object, nonneg: object = ..., *, allow_nd: object = ...) -> object: ...
71+
def isshape(x: object, nonneg: object = ..., *, allow_nd: object = ...) -> Any: ...
8372
@deprecated("will be removed in SciPy v2.0.0")
84-
def check_shape(args: object, current_shape: object = ..., *, allow_nd: object = ...) -> object: ...
73+
def check_shape(args: object, current_shape: object = ..., *, allow_nd: object = ...) -> Any: ...
8574
@deprecated("will be removed in SciPy v2.0.0")
86-
def get_sum_dtype(dtype: object) -> object: ...
75+
def get_sum_dtype(dtype: object) -> Any: ...
8776
@deprecated("will be removed in SciPy v2.0.0")
88-
def downcast_intp_index(arr: object) -> object: ...
77+
def downcast_intp_index(arr: object) -> Any: ...
8978
@deprecated("will be removed in SciPy v2.0.0")
90-
def isscalarlike(x: object) -> object: ...
79+
def isscalarlike(x: object) -> Any: ...
9180
@deprecated("will be removed in SciPy v2.0.0")
92-
def isintlike(x: object) -> object: ...
81+
def isintlike(x: object) -> Any: ...
9382
@deprecated("will be removed in SciPy v2.0.0")
94-
def isdense(x: object) -> object: ...
83+
def isdense(x: object) -> Any: ...
9584
@deprecated("will be removed in SciPy v2.0.0")
96-
def is_pydata_spmatrix(m: object) -> object: ...
85+
def is_pydata_spmatrix(m: object) -> Any: ...

scipy-stubs/sparse/construct.pyi

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# ruff: noqa: ANN401
12
# This module is not meant for public use and will be removed in SciPy v2.0.0.
3+
24
import numbers
5+
from typing import Any
36
from typing_extensions import deprecated
47

58
from . import _bsr, _coo, _csc, _csr, _dia
@@ -48,11 +51,11 @@ class dia_matrix(_dia.dia_matrix): ...
4851
class bsr_matrix(_bsr.bsr_matrix): ...
4952

5053
@deprecated("will be removed in SciPy v2.0.0")
51-
def csr_hstack(*args: object, **kwargs: object) -> object: ...
54+
def csr_hstack(*args: object, **kwargs: object) -> Any: ...
5255
@deprecated("will be removed in SciPy v2.0.0")
53-
def issparse(x: object) -> object: ...
56+
def issparse(x: object) -> Any: ...
5457
@deprecated("will be removed in SciPy v2.0.0")
55-
def check_random_state(seed: object) -> object: ...
58+
def check_random_state(seed: object) -> Any: ...
5659
@deprecated("will be removed in SciPy v2.0.0")
5760
def rng_integers(
5861
gen: object,
@@ -61,11 +64,11 @@ def rng_integers(
6164
size: object = ...,
6265
dtype: object = ...,
6366
endpoint: object = ...,
64-
) -> object: ...
67+
) -> Any: ...
6568
@deprecated("will be removed in SciPy v2.0.0")
66-
def vstack(blocks: object, format: object = ..., dtype: object = ...) -> object: ...
69+
def vstack(blocks: object, format: object = ..., dtype: object = ...) -> Any: ...
6770
@deprecated("will be removed in SciPy v2.0.0")
68-
def spdiags(data: object, diags: object, m: object = ..., n: object = ..., format: object = ...) -> object: ...
71+
def spdiags(data: object, diags: object, m: object = ..., n: object = ..., format: object = ...) -> Any: ...
6972
@deprecated("will be removed in SciPy v2.0.0")
7073
def random(
7174
m: object,
@@ -75,30 +78,30 @@ def random(
7578
dtype: object = ...,
7679
rng: object = ...,
7780
data_rvs: object = ...,
78-
) -> object: ...
81+
) -> Any: ...
7982
@deprecated("will be removed in SciPy v2.0.0")
80-
def rand(m: object, n: object, density: object = ..., format: object = ..., dtype: object = ..., rng: object = ...) -> object: ...
83+
def rand(m: object, n: object, density: object = ..., format: object = ..., dtype: object = ..., rng: object = ...) -> Any: ...
8184
@deprecated("will be removed in SciPy v2.0.0")
82-
def kron(A: object, B: object, format: object = ...) -> object: ...
85+
def kron(A: object, B: object, format: object = ...) -> Any: ...
8386
@deprecated("will be removed in SciPy v2.0.0")
84-
def kronsum(A: object, B: object, format: object = ...) -> object: ...
87+
def kronsum(A: object, B: object, format: object = ...) -> Any: ...
8588
@deprecated("will be removed in SciPy v2.0.0")
86-
def identity(n: object, dtype: object = ..., format: object = ...) -> object: ...
89+
def identity(n: object, dtype: object = ..., format: object = ...) -> Any: ...
8790
@deprecated("will be removed in SciPy v2.0.0")
88-
def block_diag(mats: object, format: object = ..., dtype: object = ...) -> object: ...
91+
def block_diag(mats: object, format: object = ..., dtype: object = ...) -> Any: ...
8992
@deprecated("will be removed in SciPy v2.0.0")
90-
def hstack(blocks: object, format: object = ..., dtype: object = ...) -> object: ...
93+
def hstack(blocks: object, format: object = ..., dtype: object = ...) -> Any: ...
9194
@deprecated("will be removed in SciPy v2.0.0")
92-
def eye(m: object, n: object = ..., k: object = ..., dtype: object = ..., format: object = ...) -> object: ...
95+
def eye(m: object, n: object = ..., k: object = ..., dtype: object = ..., format: object = ...) -> Any: ...
9396
@deprecated("will be removed in SciPy v2.0.0")
94-
def diags(diagonals: object, offsets: object = ..., shape: object = ..., format: object = ..., dtype: object = ...) -> object: ...
97+
def diags(diagonals: object, offsets: object = ..., shape: object = ..., format: object = ..., dtype: object = ...) -> Any: ...
9598
@deprecated("will be removed in SciPy v2.0.0")
96-
def bmat(blocks: object, format: object = ..., dtype: object = ...) -> object: ...
99+
def bmat(blocks: object, format: object = ..., dtype: object = ...) -> Any: ...
97100

98101
# sputils
99102
@deprecated("will be removed in SciPy v2.0.0")
100-
def get_index_dtype(arrays: object = ..., maxval: object = ..., check_contents: object = ...) -> object: ...
103+
def get_index_dtype(arrays: object = ..., maxval: object = ..., check_contents: object = ...) -> Any: ...
101104
@deprecated("will be removed in SciPy v2.0.0")
102-
def isscalarlike(x: object) -> object: ...
105+
def isscalarlike(x: object) -> Any: ...
103106
@deprecated("will be removed in SciPy v2.0.0")
104-
def upcast(*args: object) -> object: ...
107+
def upcast(*args: object) -> Any: ...

scipy-stubs/sparse/coo.pyi

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# ruff: noqa: ANN401
12
# This module is not meant for public use and will be removed in SciPy v2.0.0.
3+
24
import operator
3-
import sys
4-
from typing import type_check_only
5+
from warnings import warn
6+
from typing import Any, type_check_only
57
from typing_extensions import deprecated
68

79
from . import _base, _coo, _matrix
@@ -37,45 +39,31 @@ class spmatrix(_matrix.spmatrix): ...
3739
class coo_matrix(_coo.coo_matrix): ...
3840

3941
@deprecated("will be removed in SciPy v2.0.0")
40-
def isspmatrix_coo(x: object) -> object: ...
42+
def isspmatrix_coo(x: object) -> Any: ...
4143
@deprecated("will be removed in SciPy v2.0.0")
42-
def coo_matvec(*args: object, **kwargs: object) -> object: ...
44+
def coo_matvec(*args: object, **kwargs: object) -> Any: ...
4345
@deprecated("will be removed in SciPy v2.0.0")
44-
def coo_tocsr(*args: object, **kwargs: object) -> object: ...
46+
def coo_tocsr(*args: object, **kwargs: object) -> Any: ...
4547
@deprecated("will be removed in SciPy v2.0.0")
46-
def coo_todense(*args: object, **kwargs: object) -> object: ...
47-
48-
if sys.version_info >= (3, 12):
49-
@deprecated("will be removed in SciPy v2.0.0")
50-
def warn(
51-
message: object,
52-
category: object = ...,
53-
stacklevel: object = ...,
54-
source: object = ...,
55-
*,
56-
skip_file_prefixes: object = ...,
57-
) -> None: ...
58-
else:
59-
@deprecated("will be removed in SciPy v2.0.0")
60-
def warn(message: object, category: object = ..., stacklevel: object = ..., source: object = ...) -> None: ...
48+
def coo_todense(*args: object, **kwargs: object) -> Any: ...
6149

6250
# sputils
6351
@type_check_only
6452
@deprecated("will be removed in SciPy v2.0.0")
65-
def upcast(*args: object) -> object: ... # does not exist, but is exported anyway...?
53+
def upcast(*args: object) -> Any: ... # does not exist, but is exported anyway...?
6654
@deprecated("will be removed in SciPy v2.0.0")
67-
def upcast_char(*args: object) -> object: ...
55+
def upcast_char(*args: object) -> Any: ...
6856
@deprecated("will be removed in SciPy v2.0.0")
69-
def to_native(A: object) -> object: ...
57+
def to_native(A: object) -> Any: ...
7058
@deprecated("will be removed in SciPy v2.0.0")
71-
def getdtype(dtype: object, a: object = ..., default: object = ...) -> object: ...
59+
def getdtype(dtype: object, a: object = ..., default: object = ...) -> Any: ...
7260
@deprecated("will be removed in SciPy v2.0.0")
73-
def getdata(obj: object, dtype: object = ..., copy: object = ...) -> object: ...
61+
def getdata(obj: object, dtype: object = ..., copy: object = ...) -> Any: ...
7462
@deprecated("will be removed in SciPy v2.0.0")
75-
def isshape(x: object, nonneg: object = ..., *, allow_nd: object = ...) -> object: ...
63+
def isshape(x: object, nonneg: object = ..., *, allow_nd: object = ...) -> Any: ...
7664
@deprecated("will be removed in SciPy v2.0.0")
77-
def check_shape(args: object, current_shape: object = ..., *, allow_nd: object = ...) -> object: ...
65+
def check_shape(args: object, current_shape: object = ..., *, allow_nd: object = ...) -> Any: ...
7866
@deprecated("will be removed in SciPy v2.0.0")
79-
def check_reshape_kwargs(kwargs: object) -> object: ...
67+
def check_reshape_kwargs(kwargs: object) -> Any: ...
8068
@deprecated("will be removed in SciPy v2.0.0")
81-
def downcast_intp_index(arr: object) -> object: ...
69+
def downcast_intp_index(arr: object) -> Any: ...

scipy-stubs/sparse/csc.pyi

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
# ruff: noqa: ANN401
12
# This module is not meant for public use and will be removed in SciPy v2.0.0.
3+
4+
from typing import Any
25
from typing_extensions import deprecated
36

47
from . import _base, _csc
@@ -12,12 +15,12 @@ class spmatrix(_base.spmatrix): ...
1215
class csc_matrix(_csc.csc_matrix): ...
1316

1417
@deprecated("will be removed in SciPy v2.0.0")
15-
def isspmatrix_csc(x: object) -> object: ...
18+
def isspmatrix_csc(x: object) -> Any: ...
1619
@deprecated("will be removed in SciPy v2.0.0")
17-
def csc_tocsr(*args: object, **kwargs: object) -> object: ...
20+
def csc_tocsr(*args: object, **kwargs: object) -> Any: ...
1821
@deprecated("will be removed in SciPy v2.0.0")
19-
def expandptr(*args: object, **kwargs: object) -> object: ...
22+
def expandptr(*args: object, **kwargs: object) -> Any: ...
2023

2124
# sputils
2225
@deprecated("will be removed in SciPy v2.0.0")
23-
def upcast(*args: object) -> object: ...
26+
def upcast(*args: object) -> Any: ...

0 commit comments

Comments
 (0)