Skip to content

Commit 488f76c

Browse files
committed
review
1 parent 0b24532 commit 488f76c

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

Diff for: src/metrology_apis/__init__.py

+11-20
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
@@ -59,10 +50,10 @@ def __ne__(self, other: Self, /) -> bool: ...
5950

6051

6152
@runtime_checkable
62-
class Unit(Protocol):
63-
def __metrology_namespace__(
53+
class Unit[D: Dimension](Protocol):
54+
def __metrology_namespace__[Q: Quantity](
6455
self, /, *, api_version: str | None = None
65-
) -> MetrologyNamespace:
56+
) -> MetrologyNamespace[Q, Self, D]:
6657
"""
6758
Returns an object that has all the metrology API functions on it.
6859
Parameters
@@ -76,7 +67,7 @@ def __metrology_namespace__(
7667
"""
7768

7869
@property
79-
def dimension(self) -> Dimension: ...
70+
def dimension(self) -> D: ...
8071

8172
def __mul__(self, other: Self, /) -> Self: ...
8273
def __truediv__(self, other: Self, /) -> Self: ...
@@ -88,10 +79,10 @@ def __rpow__(self, other: int | float, /) -> Self: ...
8879

8980

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

0 commit comments

Comments
 (0)