Skip to content

Commit 99f7de6

Browse files
committed
Improve type annotations
1 parent cf3e00e commit 99f7de6

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

zigpy_znp/frames.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class GeneralFrame:
1111
header: t.CommandHeader
1212
data: t.Bytes
1313

14-
def __post_init__(self):
14+
def __post_init__(self) -> None:
1515
# We're frozen so `self.header = ...` is disallowed
1616
if not isinstance(self.header, t.CommandHeader):
1717
object.__setattr__(self, "header", t.CommandHeader(self.header))

zigpy_znp/logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
_TRACE = 5
44

55

6-
def _find_trace_level():
6+
def _find_trace_level() -> int:
77
if logging.getLevelName(_TRACE) != f"Level {_TRACE}":
88
# If a level 5 exists, use it
99
return _TRACE

zigpy_znp/types/struct.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def real_cls(cls) -> type:
1818
return next(c for c in cls.__mro__ if c.__name__ != "Optional")
1919

2020
@classmethod
21-
def _annotations(cls) -> typing.List[type]:
21+
def _annotations(cls) -> typing.Dict[str, typing.Any]:
2222
# First get our proper subclasses
2323
subclasses = []
2424

@@ -195,7 +195,7 @@ def serialize(self) -> bytes:
195195
)
196196

197197
@classmethod
198-
def deserialize(cls, data: bytes) -> "Struct":
198+
def deserialize(cls, data: bytes) -> typing.Tuple["Struct", bytes]:
199199
instance = cls()
200200

201201
for field in cls.fields():
@@ -239,7 +239,7 @@ class StructField:
239239
dynamic_type: typing.Optional[typing.Callable[[Struct], type]] = None
240240
requires: typing.Optional[typing.Callable[[Struct], bool]] = None
241241

242-
def __post_init__(self):
242+
def __post_init__(self) -> None:
243243
# Fail to initialize if the concrete type is invalid
244244
if self.dynamic_type is None:
245245
self.concrete_type

zigpy_znp/uart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _extract_frame(self) -> frames.TransportFrame:
140140

141141
return frame
142142

143-
def __repr__(self):
143+
def __repr__(self) -> str:
144144
return f"<{type(self).__name__} for {self._api}>"
145145

146146

0 commit comments

Comments
 (0)