|
27 | 27 | ) |
28 | 28 | from unittest.mock import create_autospec, patch |
29 | 29 |
|
30 | | -import nptyping # type: ignore |
| 30 | +import nptyping |
31 | 31 | import pytest |
32 | 32 | import typing_extensions |
33 | 33 | from sphinx.application import Sphinx |
@@ -241,45 +241,42 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t |
241 | 241 | # Internal tuple with following additional type cannot be flattened (specific to nptyping?) |
242 | 242 | # These cases will fail if nptyping restructures its internal module hierarchy |
243 | 243 | ( |
244 | | - nptyping.NDArray[(Any,), nptyping.Float], |
| 244 | + nptyping.NDArray[nptyping.Shape["*"], nptyping.Float], |
245 | 245 | ( |
246 | | - ":py:class:`~nptyping.types._ndarray.NDArray`\\[(:py:data:`~typing.Any`, ), " |
247 | | - ":py:class:`~nptyping.types._number.Float`]" |
| 246 | + ":py:class:`~nptyping.ndarray.NDArray`\\[:py:data:`~typing.Literal`\\['*'], " |
| 247 | + ":py:class:`~numpy.float64`]" |
248 | 248 | ), |
249 | 249 | ), |
250 | 250 | ( |
251 | | - nptyping.NDArray[(Any,), nptyping.Float[64]], |
| 251 | + nptyping.NDArray[nptyping.Shape["64"], nptyping.Float], |
252 | 252 | ( |
253 | | - ":py:class:`~nptyping.types._ndarray.NDArray`\\[(:py:data:`~typing.Any`, ), " |
254 | | - ":py:class:`~nptyping.types._number.Float`\\[64]]" |
| 253 | + ":py:class:`~nptyping.ndarray.NDArray`\\[:py:data:`~typing.Literal`\\['64'], " |
| 254 | + ":py:class:`~numpy.float64`]" |
255 | 255 | ), |
256 | 256 | ), |
257 | 257 | ( |
258 | | - nptyping.NDArray[(Any, Any), nptyping.Float], |
| 258 | + nptyping.NDArray[nptyping.Shape["*, *"], nptyping.Float], |
259 | 259 | ( |
260 | | - ":py:class:`~nptyping.types._ndarray.NDArray`\\[(:py:data:`~typing.Any`, " |
261 | | - ":py:data:`~typing.Any`), :py:class:`~nptyping.types._number.Float`]" |
| 260 | + ":py:class:`~nptyping.ndarray.NDArray`\\[:py:data:`~typing.Literal`\\['*, " |
| 261 | + "*'], :py:class:`~numpy.float64`]" |
262 | 262 | ), |
263 | 263 | ), |
264 | 264 | ( |
265 | | - nptyping.NDArray[(Any, ...), nptyping.Float], |
266 | | - ( |
267 | | - ":py:class:`~nptyping.types._ndarray.NDArray`\\[(:py:data:`~typing.Any`, :py:data:`...<Ellipsis>`), " |
268 | | - ":py:class:`~nptyping.types._number.Float`]" |
269 | | - ), |
| 265 | + nptyping.NDArray[nptyping.Shape["*, ..."], nptyping.Float], |
| 266 | + (":py:class:`~nptyping.ndarray.NDArray`\\[:py:data:`~typing.Any`, :py:class:`~numpy.float64`]"), |
270 | 267 | ), |
271 | 268 | ( |
272 | | - nptyping.NDArray[(Any, 3), nptyping.Float], |
| 269 | + nptyping.NDArray[nptyping.Shape["*, 3"], nptyping.Float], |
273 | 270 | ( |
274 | | - ":py:class:`~nptyping.types._ndarray.NDArray`\\[(:py:data:`~typing.Any`, 3), " |
275 | | - ":py:class:`~nptyping.types._number.Float`]" |
| 271 | + ":py:class:`~nptyping.ndarray.NDArray`\\[:py:data:`~typing.Literal`\\['*, 3'], " |
| 272 | + ":py:class:`~numpy.float64`]" |
276 | 273 | ), |
277 | 274 | ), |
278 | 275 | ( |
279 | | - nptyping.NDArray[(3, ...), nptyping.Float], |
| 276 | + nptyping.NDArray[nptyping.Shape["3, ..."], nptyping.Float], |
280 | 277 | ( |
281 | | - ":py:class:`~nptyping.types._ndarray.NDArray`\\[(3, :py:data:`...<Ellipsis>`)," |
282 | | - " :py:class:`~nptyping.types._number.Float`]" |
| 278 | + ":py:class:`~nptyping.ndarray.NDArray`\\[:py:data:`~typing.Literal`\\['3, ...'], " |
| 279 | + ":py:class:`~numpy.float64`]" |
283 | 280 | ), |
284 | 281 | ), |
285 | 282 | ], |
@@ -312,6 +309,7 @@ def test_format_annotation(inv: Inventory, annotation: Any, expected_result: str |
312 | 309 | if "typing" in expected_result or "nptyping" in expected_result or __name__ in expected_result: |
313 | 310 | expected_result = expected_result.replace("~typing", "typing") |
314 | 311 | expected_result = expected_result.replace("~nptyping", "nptyping") |
| 312 | + expected_result = expected_result.replace("~numpy", "numpy") |
315 | 313 | expected_result = expected_result.replace("~" + __name__, __name__) |
316 | 314 | conf = create_autospec(Config, typehints_fully_qualified=True, _annotation_globals=globals()) |
317 | 315 | assert format_annotation(annotation, conf) == expected_result |
|
0 commit comments