|
1 | 1 | import logging |
2 | 2 | import warnings |
3 | 3 | from array import array |
| 4 | +from collections.abc import Callable, Collection |
4 | 5 | from logging import DEBUG as LVL_DEBUG |
5 | 6 | from math import ceil |
6 | | -from typing import Any, Callable, Collection, Final, List, Literal, Optional, Type, Union |
7 | | - |
8 | | -from pyartnet.errors import ChannelOutOfUniverseError, ChannelValueOutOfBoundsError, \ |
9 | | - ChannelWidthError, ValueCountDoesNotMatchChannelWidthError |
| 7 | +from typing import Any, Final, List, Literal, Optional, Type, Union |
| 8 | + |
| 9 | +from pyartnet.errors import ( |
| 10 | + ChannelOutOfUniverseError, |
| 11 | + ChannelValueOutOfBoundsError, |
| 12 | + ChannelWidthError, |
| 13 | + ValueCountDoesNotMatchChannelWidthError, |
| 14 | +) |
10 | 15 | from pyartnet.output_correction import linear |
11 | 16 |
|
12 | 17 | from ..fades import FadeBase, LinearFade |
13 | 18 | from .channel_fade import ChannelBoundFade |
14 | 19 | from .output_correction import OutputCorrection |
15 | 20 | from .universe import BaseUniverse |
16 | 21 |
|
| 22 | + |
17 | 23 | log = logging.getLogger('pyartnet.Channel') |
18 | 24 |
|
19 | 25 |
|
|
28 | 34 | class Channel(OutputCorrection): |
29 | 35 | def __init__(self, universe: BaseUniverse, |
30 | 36 | start: int, width: int, |
31 | | - byte_size: int = 1, byte_order: Literal['big', 'little'] = 'little'): |
| 37 | + byte_size: int = 1, byte_order: Literal['big', 'little'] = 'little') -> None: |
32 | 38 | super().__init__() |
33 | 39 |
|
34 | 40 | # Validate Boundaries |
@@ -139,7 +145,7 @@ def to_buffer(self, buf: bytearray): |
139 | 145 | def add_fade(self, values: Collection[Union[int, FadeBase]], duration_ms: int, |
140 | 146 | fade_class: Type[FadeBase] = LinearFade): |
141 | 147 | warnings.warn( |
142 | | - f"{self.set_fade.__name__:s} is deprecated, use {self.set_fade.__name__:s} instead", DeprecationWarning) |
| 148 | + f'{self.set_fade.__name__:s} is deprecated, use {self.set_fade.__name__:s} instead', DeprecationWarning) |
143 | 149 | return self.set_fade(values, duration_ms, fade_class) |
144 | 150 |
|
145 | 151 | # noinspection PyProtectedMember |
@@ -198,5 +204,5 @@ def __await__(self): |
198 | 204 | yield from self._current_fade.event.wait().__await__() |
199 | 205 | return True |
200 | 206 |
|
201 | | - def __repr__(self): |
| 207 | + def __repr__(self) -> str: |
202 | 208 | return f'<{self.__class__.__name__:s} {self._start:d}/{self._width:d} {self._byte_size * 8:d}bit>' |
0 commit comments