5
5
Final ,
6
6
Protocol ,
7
7
Self ,
8
- TypeAlias ,
9
8
override ,
10
9
runtime_checkable ,
11
10
)
16
15
__all__ = ["__version__" , "Dimension" , "Quantity" , "Unit" ]
17
16
18
17
19
- VT : TypeAlias = Any
20
- DT : TypeAlias = Any
21
- UT : TypeAlias = Any
18
+ type _AnyValue = Any
19
+ type _AnyDimension = Any
20
+ type _AnyUnit = Unit [_AnyDimension ]
21
+ type _AnyQuantity = Quantity [_AnyValue , _AnyUnit , _AnyDimension ]
22
22
23
23
24
24
@runtime_checkable
25
- class MetrologyNamespace [Q : Quantity [ VT , UT , DT ], V : VT , U : Unit [ DT ] , D : Dimension ](
25
+ class MetrologyNamespace [Q : _AnyQuantity , V : _AnyValue , U : _AnyUnit , D : Dimension ](
26
26
Protocol
27
27
):
28
28
@staticmethod
@@ -39,7 +39,7 @@ def asquantity(obj: Q | V, *, unit: U) -> Q: ...
39
39
class Dimension (Protocol ):
40
40
def __metrology_namespace__ (
41
41
self , / , * , api_version : str | None = None
42
- ) -> MetrologyNamespace ["Quantity[VT, UT, DT]" , VT , "Unit[DT]" , Self ]:
42
+ ) -> MetrologyNamespace [_AnyQuantity , _AnyValue , _AnyUnit , Self ]:
43
43
"""
44
44
Return an object that has all the metrology API functions on it.
45
45
@@ -76,7 +76,7 @@ def __rtruediv__(self, other: Self, /) -> Self: ...
76
76
class Unit [D : Dimension ](Protocol ):
77
77
def __metrology_namespace__ (
78
78
self , / , * , api_version : str | None = None
79
- ) -> MetrologyNamespace ["Quantity[VT, UT, DT]" , VT , Self , D ]:
79
+ ) -> MetrologyNamespace [_AnyQuantity , _AnyValue , Self , D ]:
80
80
"""
81
81
Return an object that has all the metrology API functions on it.
82
82
@@ -113,7 +113,7 @@ def __rtruediv__(self, other: Self, /) -> Self: ...
113
113
114
114
115
115
@runtime_checkable
116
- class Quantity [V , U : Unit [ DT ] , D : Dimension ](Protocol ):
116
+ class Quantity [V , U : _AnyUnit , D : Dimension ](Protocol ):
117
117
def __metrology_namespace__ (
118
118
self , / , * , api_version : str | None = None
119
119
) -> MetrologyNamespace [Self , V , U , D ]:
0 commit comments