12
12
13
13
"""
14
14
15
+ from __future__ import annotations
16
+
15
17
import struct
16
18
17
19
from .packet import Packet
20
22
class LocationPacket (Packet ):
21
23
"""A packet of latitude, longitude, and altitude values."""
22
24
23
- _FMT_PARSE = "<xxfffx"
24
- PACKET_LENGTH = struct .calcsize (_FMT_PARSE )
25
+ _FMT_PARSE : str = "<xxfffx"
26
+ PACKET_LENGTH : int = struct .calcsize (_FMT_PARSE )
25
27
# _FMT_CONSTRUCT doesn't include the trailing checksum byte.
26
- _FMT_CONSTRUCT = "<2sfff"
27
- _TYPE_HEADER = b"!L"
28
+ _FMT_CONSTRUCT : str = "<2sfff"
29
+ _TYPE_HEADER : bytes = b"!L"
28
30
29
- def __init__ (self , latitude , longitude , altitude ) :
31
+ def __init__ (self , latitude : float , longitude : float , altitude : float ) -> None :
30
32
"""Construct a LocationPacket from the given values."""
31
33
self ._latitude = latitude
32
34
self ._longitude = longitude
33
35
self ._altitude = altitude
34
36
35
- def to_bytes (self ):
37
+ def to_bytes (self ) -> bytes :
36
38
"""Return the bytes needed to send this packet."""
37
39
partial_packet = struct .pack (
38
40
self ._FMT_CONSTRUCT ,
@@ -44,17 +46,17 @@ def to_bytes(self):
44
46
return self .add_checksum (partial_packet )
45
47
46
48
@property
47
- def latitude (self ):
49
+ def latitude (self ) -> float :
48
50
"""The latitude value."""
49
51
return self ._latitude
50
52
51
53
@property
52
- def longitude (self ):
54
+ def longitude (self ) -> float :
53
55
"""The longitude value."""
54
56
return self ._longitude
55
57
56
58
@property
57
- def altitude (self ):
59
+ def altitude (self ) -> float :
58
60
"""The altitude value."""
59
61
return self ._altitude
60
62
0 commit comments