@@ -4,8 +4,8 @@ import numpy as np
44from typing_extensions import Never , Self , override
55
66_Backend : TypeAlias = Literal ["sleef" , "longdouble" ]
7- _IntoQuad : TypeAlias = QuadPrecision | float | str
8- _CastsQuad : TypeAlias = _IntoQuad | np .floating [ Any ] | np . integer [ Any ] | np . bool_
7+ _IntoQuad : TypeAlias = QuadPrecision | float | str | np . floating [ Any ] | np . integer [ Any ]
8+ _CastsQuad : TypeAlias = _IntoQuad | np .bool_
99
1010@final
1111class QuadPrecDType (np .dtype [QuadPrecision ]): # type: ignore[misc, type-var] # pyright: ignore[reportGeneralTypeIssues, reportInvalidTypeArguments]
@@ -64,8 +64,15 @@ class QuadPrecDType(np.dtype[QuadPrecision]): # type: ignore[misc, type-var] #
6464 @override
6565 def __getitem__ (self , key : Never , / ) -> Self : ... # type: ignore[override]
6666
67+ # NOTE: Until `QuadPrecision` will become a subclass of `np.generic`, this class cannot
68+ # be considered "type-safe".
6769@final
68- class QuadPrecision : # NOTE: It doesn't inherit from `np.generic` which is type-unsafe
70+ class QuadPrecision :
71+ # NOTE: At runtime this constructor also accepts array-likes, for which it returns
72+ # `np.ndarray` instances with `dtype=QuadPrecDType()`.
73+ # But because of mypy limitations, it is currently impossible to annotate
74+ # constructors that do no return instances of their class (or a subclass thereof).
75+ # See https://github.com/python/mypy/issues/18343#issuecomment-2571784915
6976 def __new__ (cls , / , value : _IntoQuad , backend : _Backend = "sleef" ) -> Self : ...
7077
7178 # Rich comparison operators
0 commit comments