Skip to content

Commit 8686220

Browse files
committed
review
1 parent 8d436bf commit 8686220

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

src/metrology_apis/__init__.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,23 @@
99

1010

1111
@runtime_checkable
12-
class MetrologyNamespace[Q: Quantity, U: Unit, D: Dimension](Protocol):
12+
class MetrologyNamespace[Q: Quantity[V, U, D], V, U: Unit[D], D: Dimension](Protocol):
1313

1414
@staticmethod
1515
def asdimension(obj: str | D) -> D: ...
1616

1717
@staticmethod
18-
def asunit(obj) -> U[D]: ...
18+
def asunit(obj: str | U) -> U: ...
1919

2020
@staticmethod
21-
def asquantity(obj: V, unit: obj) -> Q[V, U[D]]: ...
22-
23-
@property
24-
def Dimension(self) -> D: ...
25-
26-
@property
27-
def Unit(self) -> U: ...
28-
29-
@property
30-
def Quantity(self) -> Q: ...
21+
def asquantity(obj: Q | V, *, unit: U) -> Q: ...
3122

3223

3324
@runtime_checkable
3425
class Dimension(Protocol):
35-
def __metrology_namespace__(
26+
def __metrology_namespace__[Q: Quantity, U: Unit](
3627
self, /, *, api_version: str | None = None
37-
) -> MetrologyNamespace:
28+
) -> MetrologyNamespace[Q, U, Self]:
3829
"""
3930
Returns an object that has all the metrology API functions on it.
4031
Parameters
@@ -56,10 +47,10 @@ def __rtruediv__(self, other: Self, /) -> Self: ...
5647

5748

5849
@runtime_checkable
59-
class Unit(Protocol):
60-
def __metrology_namespace__(
50+
class Unit[D: Dimension](Protocol):
51+
def __metrology_namespace__[Q: Quantity](
6152
self, /, *, api_version: str | None = None
62-
) -> MetrologyNamespace:
53+
) -> MetrologyNamespace[Q, Self, D]:
6354
"""
6455
Returns an object that has all the metrology API functions on it.
6556
Parameters
@@ -73,7 +64,7 @@ def __metrology_namespace__(
7364
"""
7465

7566
@property
76-
def dimension(self) -> Dimension: ...
67+
def dimension(self) -> D: ...
7768

7869
def __mul__(self, other: Self, /) -> Self: ...
7970
def __truediv__(self, other: Self, /) -> Self: ...
@@ -85,10 +76,10 @@ def __rpow__(self, other: int | float, /) -> Self: ...
8576

8677

8778
@runtime_checkable
88-
class Quantity[V, U: Unit](Protocol):
79+
class Quantity[V, U: Unit[D], D: Dimension](Protocol):
8980
def __metrology_namespace__(
9081
self, /, *, api_version: str | None = None
91-
) -> MetrologyNamespace:
82+
) -> MetrologyNamespace[Self, U, D]:
9283
"""
9384
Returns an object that has all the metrology API functions on it.
9485
Parameters

0 commit comments

Comments
 (0)