From c6fc6884d3c9bc68872a7adaae2974143a910eac Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Mon, 19 Oct 2020 16:03:18 +0200 Subject: DEP: Formally deprecate the use of `typeDict` `typeDict` is a deprecated alias for `sctypeDict` and has been so for >= 14 years (https://github.com/numpy/numpy/commit/668950285c407593a368336ff2e737c5da84af7d) --- numpy/__init__.py | 4 ++++ numpy/__init__.pyi | 1 - numpy/core/numerictypes.py | 2 +- numpy/core/numerictypes.pyi | 2 +- tools/functions_missing_types.py | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/numpy/__init__.py b/numpy/__init__.py index a242bb7df..a0c9a44bc 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -192,6 +192,10 @@ else: ) for n, n2 in [("long", "int"), ("unicode", "str")] }) + __deprecated_attrs__["typeDict"] = ( + getattr(core.numerictypes, "typeDict"), + "`np.typeDict` is a deprecated alias for `np.sctypeDict`." + ) from .core import round, abs, max, min # now that numpy modules are imported, can initialize limits diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 656048173..a26b70af8 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -558,7 +558,6 @@ trim_zeros: Any triu: Any triu_indices: Any triu_indices_from: Any -typeDict: Any typecodes: Any typename: Any union1d: Any diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index e705dd3ea..5a9c50ee3 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -91,7 +91,7 @@ from numpy.core.multiarray import ( from numpy.core.overrides import set_module # we add more at the bottom -__all__ = ['sctypeDict', 'typeDict', 'sctypes', +__all__ = ['sctypeDict', 'sctypes', 'ScalarType', 'obj2sctype', 'cast', 'nbytes', 'sctype2char', 'maximum_sctype', 'issctype', 'typecodes', 'find_common_type', 'issubdtype', 'datetime_data', 'datetime_as_string', diff --git a/numpy/core/numerictypes.pyi b/numpy/core/numerictypes.pyi index 192015ff1..238495fd3 100644 --- a/numpy/core/numerictypes.pyi +++ b/numpy/core/numerictypes.pyi @@ -26,4 +26,4 @@ def find_common_type( ) -> dtype: ... # TODO: Add annotations for the following objects: -# typeDict, nbytes, cast, ScalarType & typecodes +# nbytes, cast, ScalarType & typecodes diff --git a/tools/functions_missing_types.py b/tools/functions_missing_types.py index c2fe156f0..b283f5a35 100755 --- a/tools/functions_missing_types.py +++ b/tools/functions_missing_types.py @@ -45,6 +45,7 @@ EXCLUDE_LIST = { "safe_eval", "set_numeric_ops", "test", + "typeDict", # Builtins "bool", "complex", -- cgit v1.2.1