|
2 | 2 | # Copyright © 2022 Frequenz Energy-as-a-Service GmbH |
3 | 3 |
|
4 | 4 | """Component data types for data coming from a microgrid.""" |
5 | | -from __future__ import annotations |
6 | 5 |
|
7 | 6 | from abc import ABC, abstractmethod |
8 | 7 | from dataclasses import dataclass, field |
9 | 8 | from datetime import datetime, timezone |
| 9 | +from typing import Self |
10 | 10 |
|
11 | 11 | # pylint: disable=no-name-in-module |
12 | 12 | from frequenz.api.microgrid.battery_pb2 import ComponentState as PbBatteryComponentState |
@@ -54,7 +54,7 @@ def _set_raw(self, raw: PbComponentData) -> None: |
54 | 54 |
|
55 | 55 | @classmethod |
56 | 56 | @abstractmethod |
57 | | - def from_proto(cls, raw: PbComponentData) -> ComponentData: |
| 57 | + def from_proto(cls, raw: PbComponentData) -> Self: |
58 | 58 | """Create ComponentData from a protobuf message. |
59 | 59 |
|
60 | 60 | Args: |
@@ -93,7 +93,7 @@ class MeterData(ComponentData): |
93 | 93 | """The AC power frequency in Hertz (Hz).""" |
94 | 94 |
|
95 | 95 | @classmethod |
96 | | - def from_proto(cls, raw: PbComponentData) -> MeterData: |
| 96 | + def from_proto(cls, raw: PbComponentData) -> Self: |
97 | 97 | """Create MeterData from a protobuf message. |
98 | 98 |
|
99 | 99 | Args: |
@@ -206,7 +206,7 @@ class BatteryData(ComponentData): # pylint: disable=too-many-instance-attribute |
206 | 206 | """List of errors in protobuf struct.""" |
207 | 207 |
|
208 | 208 | @classmethod |
209 | | - def from_proto(cls, raw: PbComponentData) -> BatteryData: |
| 209 | + def from_proto(cls, raw: PbComponentData) -> Self: |
210 | 210 | """Create BatteryData from a protobuf message. |
211 | 211 |
|
212 | 212 | Args: |
@@ -316,7 +316,7 @@ class InverterData(ComponentData): # pylint: disable=too-many-instance-attribut |
316 | 316 | """List of errors from the component.""" |
317 | 317 |
|
318 | 318 | @classmethod |
319 | | - def from_proto(cls, raw: PbComponentData) -> InverterData: |
| 319 | + def from_proto(cls, raw: PbComponentData) -> Self: |
320 | 320 | """Create InverterData from a protobuf message. |
321 | 321 |
|
322 | 322 | Args: |
@@ -436,7 +436,7 @@ class EVChargerData(ComponentData): # pylint: disable=too-many-instance-attribu |
436 | 436 | """The state of the ev charger.""" |
437 | 437 |
|
438 | 438 | @classmethod |
439 | | - def from_proto(cls, raw: PbComponentData) -> EVChargerData: |
| 439 | + def from_proto(cls, raw: PbComponentData) -> Self: |
440 | 440 | """Create EVChargerData from a protobuf message. |
441 | 441 |
|
442 | 442 | Args: |
|
0 commit comments