1
1
"""Metrology APIs."""
2
2
3
- from typing import Any , Final , Generic , Protocol , Self , TypeVar , override , runtime_checkable
3
+ from typing import (
4
+ Final ,
5
+ Protocol ,
6
+ Self ,
7
+ TypeVar ,
8
+ override ,
9
+ runtime_checkable ,
10
+ )
4
11
5
12
import optype as op
6
13
7
14
__version__ : Final = "0.0.1.dev0"
8
15
__all__ = ["__version__" , "Dimension" , "Quantity" , "Unit" ]
9
16
10
17
11
- VT = TypeVar ('VT' )
12
- DT = TypeVar ('DT' , bound = ' Dimension' )
13
- UT = TypeVar ('UT' , bound = ' Unit[DT]' )
18
+ VT = TypeVar ("VT" )
19
+ DT = TypeVar ("DT" , bound = " Dimension" )
20
+ UT = TypeVar ("UT" , bound = " Unit[DT]" )
14
21
15
- @runtime_checkable
16
- class MetrologyNamespace [Q : Quantity [VT , UT , DT ], V , U : Unit [DT ], D : Dimension ](Protocol ):
17
22
23
+ @runtime_checkable
24
+ class MetrologyNamespace [Q : Quantity [VT , UT , DT ], V , U : Unit [DT ], D : Dimension ](
25
+ Protocol
26
+ ):
18
27
@staticmethod
19
28
def asdimension (obj : str | D ) -> D : ...
20
29
@@ -31,12 +40,12 @@ def __metrology_namespace__[Q: Quantity[VT, UT, DT], V, U: Unit[DT]](
31
40
self , / , * , api_version : str | None = None
32
41
) -> MetrologyNamespace [Q , V , U , Self ]:
33
42
"""
34
- Returns an object that has all the metrology API functions on it.
43
+ Return an object that has all the metrology API functions on it.
35
44
36
45
Parameters
37
46
----------
38
- api_version: str or None
39
- string representing the version of the metrology API
47
+ api_version : str or None
48
+ String representing the version of the metrology API
40
49
specification to be returned. If it is `None`, it should
41
50
return the namespace corresponding to latest version of the
42
51
metrology API specification. If the given version is invalid
@@ -45,7 +54,7 @@ def __metrology_namespace__[Q: Quantity[VT, UT, DT], V, U: Unit[DT]](
45
54
46
55
Returns
47
56
-------
48
- out: Any
57
+ Any
49
58
An object representing the metrology API namespace. It
50
59
should have every top-level function defined in the
51
60
specification as an attribute. It may contain other public
@@ -67,12 +76,12 @@ def __metrology_namespace__[Q: Quantity[VT, UT, DT], V](
67
76
self , / , * , api_version : str | None = None
68
77
) -> MetrologyNamespace [Q , V , Self , D ]:
69
78
"""
70
- Returns an object that has all the metrology API functions on it.
79
+ Return an object that has all the metrology API functions on it.
71
80
72
81
Parameters
73
82
----------
74
- api_version: str or None
75
- string representing the version of the metrology API
83
+ api_version : str or None
84
+ String representing the version of the metrology API
76
85
specification to be returned. If it is `None`, it should
77
86
return the namespace corresponding to latest version of the
78
87
metrology API specification. If the given version is invalid
@@ -81,8 +90,8 @@ def __metrology_namespace__[Q: Quantity[VT, UT, DT], V](
81
90
82
91
Returns
83
92
-------
84
- out: Any
85
- an object representing the metrology API namespace. It should
93
+ Any
94
+ An object representing the metrology API namespace. It should
86
95
have every top-level function defined in the specification as
87
96
an attribute. It may contain other public names as well, but
88
97
it is recommended to only include those names that are part
@@ -100,19 +109,18 @@ def __rmul__(self, other: Self, /) -> Self: ...
100
109
def __rtruediv__ (self , other : Self , / ) -> Self : ...
101
110
102
111
103
-
104
112
@runtime_checkable
105
113
class Quantity [V , U : Unit [DT ], D : Dimension ](Protocol ):
106
114
def __metrology_namespace__ (
107
115
self , / , * , api_version : str | None = None
108
116
) -> MetrologyNamespace [Self , V , U , D ]:
109
117
"""
110
- Returns an object that has all the metrology API functions on it.
118
+ Return an object that has all the metrology API functions on it.
111
119
112
120
Parameters
113
121
----------
114
- api_version: str or None
115
- string representing the version of the metrology API
122
+ api_version : str or None
123
+ String representing the version of the metrology API
116
124
specification to be returned. If it is `None`, it should
117
125
return the namespace corresponding to the latest version of
118
126
the metrology API specification. If the given version is
@@ -121,8 +129,8 @@ def __metrology_namespace__(
121
129
122
130
Returns
123
131
-------
124
- out: Any
125
- an object representing the metrology API namespace. It should
132
+ Any
133
+ An object representing the metrology API namespace. It should
126
134
have every top-level function defined in the specification as
127
135
an attribute. It may contain other public names as well, but it
128
136
is recommended to only include those names that are part of the
0 commit comments