19
19
from .packet import Packet
20
20
21
21
try :
22
- from typing import Optional # adjust these as needed
22
+ from typing import Optional , Tuple # adjust these as needed
23
23
except ImportError :
24
24
pass
25
25
@@ -33,22 +33,22 @@ class ColorPacket(Packet):
33
33
_FMT_CONSTRUCT : str = "<2s3B"
34
34
_TYPE_HEADER : bytes = b"!C"
35
35
36
- def __init__ (self , color : Optional [ Packet ] ) -> None :
36
+ def __init__ (self , color : Tuple ) -> None :
37
37
"""Construct a ColorPacket from a 3-element :class:`tuple` of RGB
38
38
values, or from an int color value 0xRRGGBB.
39
39
40
40
:param tuple/int color: an RGB :class:`tuple` ``(red, green, blue)``
41
41
or an int color value ``0xRRGGBB``
42
42
"""
43
43
if isinstance (color , int ):
44
- self ._color = tuple (color .to_bytes (3 , "big" ))
44
+ self ._color : Tuple = tuple (color .to_bytes (3 , "big" ))
45
45
elif len (color ) == 3 and all (0 <= c <= 255 for c in color ):
46
46
self ._color = color
47
47
else :
48
48
raise ValueError ("Color must be an integer 0xRRGGBB or a tuple(r,g,b)" )
49
49
50
50
@classmethod
51
- def parse_private (cls , packet : Optional [ Packet ] ) -> Optional [Packet ]:
51
+ def parse_private (cls , packet : bytes ) -> Optional [Packet ]:
52
52
"""Construct a ColorPacket from an incoming packet.
53
53
Do not call this directly; call Packet.from_bytes() instead.
54
54
pylint makes it difficult to call this method _parse(), hence the name.
0 commit comments