Skip to content

Commit a17939d

Browse files
Refactor optional type declarations in _component.py
This commit refactors the declarations of types in format `Optional[X]` to `X | None`. Signed-off-by: Tiyash Basu <[email protected]>
1 parent 7b4a9fb commit a17939d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/frequenz/sdk/microgrid/component/_component.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from dataclasses import dataclass
99
from enum import Enum
10-
from typing import Optional
1110

1211
import frequenz.api.common.components_pb2 as components_pb
1312
import frequenz.api.microgrid.inverter_pb2 as inverter_pb
@@ -32,7 +31,7 @@ class InverterType(ComponentType):
3231
def _component_type_from_protobuf(
3332
component_category: components_pb.ComponentCategory.ValueType,
3433
component_metadata: inverter_pb.Metadata,
35-
) -> Optional[ComponentType]:
34+
) -> ComponentType | None:
3635
"""Convert a protobuf InverterType message to Component enum.
3736
3837
For internal-only use by the `microgrid` package.
@@ -112,7 +111,7 @@ class Component:
112111

113112
component_id: int
114113
category: ComponentCategory
115-
type: Optional[ComponentType] = None
114+
type: ComponentType | None = None
116115

117116
def is_valid(self) -> bool:
118117
"""Check if this instance contains valid data.

0 commit comments

Comments
 (0)