16
16
Without the plugin the type will default to `ctypes.c_int64`.
17
17
18
18
.. versionadded:: 1.22
19
+ .. deprecated:: 2.3
19
20
20
21
Examples
21
22
--------
35
36
36
37
import numpy as np
37
38
38
- __all__ = ()
39
+ __all__ : list [ str ] = []
39
40
40
41
41
42
def _get_precision_dict () -> dict [str , str ]:
@@ -111,18 +112,15 @@ def _get_c_intp_name() -> str:
111
112
from mypy .nodes import MypyFile , ImportFrom , Statement
112
113
from mypy .build import PRI_MED
113
114
114
-
115
115
_HookFunc : TypeAlias = Callable [[AnalyzeTypeContext ], mypy .types .Type ]
116
116
117
-
118
117
def _hook (ctx : AnalyzeTypeContext ) -> mypy .types .Type :
119
118
"""Replace a type-alias with a concrete ``NBitBase`` subclass."""
120
119
typ , _ , api = ctx
121
120
name = typ .name .split ("." )[- 1 ]
122
121
name_new = _PRECISION_DICT [f"{ _MODULE } ._nbit.{ name } " ]
123
122
return cast ("TypeAnalyser" , api ).named_type (name_new )
124
123
125
-
126
124
def _index (iterable : Iterable [Statement ], id : str ) -> int :
127
125
"""Identify the first ``ImportFrom`` instance the specified `id`."""
128
126
for i , value in enumerate (iterable ):
@@ -146,7 +144,6 @@ def _override_imports(
146
144
i = _index (lst , module )
147
145
lst [i ] = import_obj
148
146
149
-
150
147
class _NumpyPlugin (Plugin ):
151
148
"""A mypy plugin for handling versus numpy-specific typing tasks."""
152
149
@@ -186,9 +183,15 @@ def get_additional_deps(
186
183
)
187
184
return [(PRI_MED , fullname , - 1 )]
188
185
189
-
190
186
def plugin (version : str ) -> type :
191
- """An entry-point for mypy."""
187
+ import warnings
188
+
189
+ warnings .warn (
190
+ "`numpy.typing.mypy_plugin` is deprecated, and will be removed in "
191
+ "a future release." ,
192
+ category = DeprecationWarning ,
193
+ stacklevel = 3 ,
194
+ )
192
195
return _NumpyPlugin
193
196
194
197
except ModuleNotFoundError as e :
0 commit comments