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
+ .. deprecated:: 2.3
20
21
21
22
Examples
22
23
--------
32
33
33
34
"""
34
35
35
- from typing import Final
36
+ from collections .abc import Callable , Iterable
37
+ from typing import TYPE_CHECKING , Final , TypeAlias , cast
36
38
37
39
import numpy as np
38
40
@@ -101,9 +103,6 @@ def _get_c_intp_name() -> str:
101
103
102
104
103
105
try :
104
- from collections .abc import Callable , Iterable
105
- from typing import TYPE_CHECKING , TypeAlias , cast
106
-
107
106
if TYPE_CHECKING :
108
107
from mypy .typeanal import TypeAnalyser
109
108
@@ -112,6 +111,13 @@ def _get_c_intp_name() -> str:
112
111
from mypy .nodes import MypyFile , ImportFrom , Statement
113
112
from mypy .build import PRI_MED
114
113
114
+ except ModuleNotFoundError as e :
115
+
116
+ def plugin (version : str ) -> type :
117
+ raise e
118
+
119
+ else :
120
+
115
121
_HookFunc : TypeAlias = Callable [[AnalyzeTypeContext ], mypy .types .Type ]
116
122
117
123
def _hook (ctx : AnalyzeTypeContext ) -> mypy .types .Type :
@@ -186,15 +192,13 @@ def get_additional_deps(
186
192
def plugin (version : str ) -> type :
187
193
import warnings
188
194
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 ,
195
+ plugin = "numpy.typing.mypy_plugin"
196
+ # Deprecated 2025-01-10, NumPy 2.3
197
+ warn_msg = (
198
+ f"`{ plugin } ` is deprecated, and will be removed in a future "
199
+ f"release. Please remove `plugins = { plugin } ` in your mypy config."
200
+ f"(deprecated in NumPy 2.3)"
194
201
)
195
- return _NumpyPlugin
196
-
197
- except ModuleNotFoundError as e :
202
+ warnings .warn (warn_msg , DeprecationWarning , stacklevel = 3 )
198
203
199
- def plugin (version : str ) -> type :
200
- raise e
204
+ return _NumpyPlugin
0 commit comments