1
1
"""Metrology APIs."""
2
2
3
3
from typing import (
4
+ Any ,
4
5
Final ,
5
6
Protocol ,
6
7
Self ,
7
- TypeVar ,
8
+ TypeAlias ,
8
9
override ,
9
10
runtime_checkable ,
10
11
)
15
16
__all__ = ["__version__" , "Dimension" , "Quantity" , "Unit" ]
16
17
17
18
18
- VT = TypeVar ( "VT" )
19
- DT = TypeVar ( "DT" , bound = "Dimension" )
20
- UT = TypeVar ( "UT" , bound = "Unit[DT]" )
19
+ VT : TypeAlias = Any
20
+ DT : TypeAlias = Any
21
+ UT : TypeAlias = Any
21
22
22
23
23
24
@runtime_checkable
24
- class MetrologyNamespace [Q : Quantity [VT , UT , DT ], V , U : Unit [DT ], D : Dimension ](
25
+ class MetrologyNamespace [Q : Quantity [VT , UT , DT ], V : VT , U : Unit [DT ], D : Dimension ](
25
26
Protocol
26
27
):
27
28
@staticmethod
@@ -36,9 +37,9 @@ def asquantity(obj: Q | V, *, unit: U) -> Q: ...
36
37
37
38
@runtime_checkable
38
39
class Dimension (Protocol ):
39
- def __metrology_namespace__ [ Q : Quantity [ VT , UT , DT ], V , U : Unit [ DT ]] (
40
+ def __metrology_namespace__ (
40
41
self , / , * , api_version : str | None = None
41
- ) -> MetrologyNamespace [Q , V , U , Self ]:
42
+ ) -> MetrologyNamespace ["Quantity[VT, UT, DT]" , VT , "Unit[DT]" , Self ]:
42
43
"""
43
44
Return an object that has all the metrology API functions on it.
44
45
@@ -61,6 +62,7 @@ def __metrology_namespace__[Q: Quantity[VT, UT, DT], V, U: Unit[DT]](
61
62
names as well, but it is recommended to only include those
62
63
names that are part of the specification.
63
64
"""
65
+ ...
64
66
65
67
def __mul__ (self , other : Self , / ) -> Self : ...
66
68
def __truediv__ (self , other : Self , / ) -> Self : ...
@@ -72,9 +74,9 @@ def __rtruediv__(self, other: Self, /) -> Self: ...
72
74
73
75
@runtime_checkable
74
76
class Unit [D : Dimension ](Protocol ):
75
- def __metrology_namespace__ [ Q : Quantity [ VT , UT , DT ], V ] (
77
+ def __metrology_namespace__ (
76
78
self , / , * , api_version : str | None = None
77
- ) -> MetrologyNamespace [Q , V , Self , D ]:
79
+ ) -> MetrologyNamespace ["Quantity[VT, UT, DT]" , VT , Self , D ]:
78
80
"""
79
81
Return an object that has all the metrology API functions on it.
80
82
@@ -97,6 +99,7 @@ def __metrology_namespace__[Q: Quantity[VT, UT, DT], V](
97
99
it is recommended to only include those names that are part
98
100
of the specification.
99
101
"""
102
+ ...
100
103
101
104
@property
102
105
def dimension (self ) -> D : ...
@@ -136,6 +139,7 @@ def __metrology_namespace__(
136
139
is recommended to only include those names that are part of the
137
140
specification.
138
141
"""
142
+ ...
139
143
140
144
@property
141
145
def value (self ) -> V : ...
0 commit comments