Skip to content

Commit b8add05

Browse files
committed
made a _Numerical DataType
Both `Int` and `Float` inherit from it.
1 parent 8dab77e commit b8add05

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/fastcs/datatypes.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,32 @@ def dtype(self) -> type[T]: # Using property due to lack of Generic ClassVars
2222
pass
2323

2424

25-
@dataclass(frozen=True)
26-
class Int(DataType[int]):
27-
"""`DataType` mapping to builtin ``int``."""
25+
T_Numerical = TypeVar("T_Numerical", int, float)
26+
2827

28+
@dataclass(frozen=True)
29+
class _Numerical(DataType[T_Numerical]):
2930
units: str | None = None
3031
min: int | None = None
3132
max: int | None = None
3233
min_alarm: int | None = None
3334
max_alarm: int | None = None
3435

36+
37+
@dataclass(frozen=True)
38+
class Int(_Numerical[int]):
39+
"""`DataType` mapping to builtin ``int``."""
40+
3541
@property
3642
def dtype(self) -> type[int]:
3743
return int
3844

3945

4046
@dataclass(frozen=True)
41-
class Float(DataType[float]):
47+
class Float(_Numerical[float]):
4248
"""`DataType` mapping to builtin ``float``."""
4349

4450
prec: int = 2
45-
units: str | None = None
46-
min: float | None = None
47-
max: float | None = None
48-
min_alarm: float | None = None
49-
max_alarm: float | None = None
5051

5152
@property
5253
def dtype(self) -> type[float]:

0 commit comments

Comments
 (0)