Skip to content

Commit 259c8ef

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b2c3e0c commit 259c8ef

File tree

3 files changed

+49
-34
lines changed

3 files changed

+49
-34
lines changed

uoshardware/abstractions.py

+16-14
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,13 @@ class UOSInterface(metaclass=ABCMeta):
182182
def execute_instruction(self, packet: NPCPacket) -> ComResult: # dead: disable
183183
"""Abstract method for executing instructions on UOSInterfaces.
184184
185-
:param packet: A tuple containing the uint8 npc packet for the UOS instruction.
185+
:param packet: A tuple containing the uint8 npc packet for the
186+
UOS instruction.
186187
:returns: ComResult object.
187188
:raises: UOSUnsupportedError if the interface hasn't been built
188-
correctly.
189+
correctly.
189190
:raises: UOSCommunicationError if there is a problem completing
190-
the action.
191+
the action.
191192
"""
192193
raise UOSUnsupportedError(
193194
"UOSInterfaces must over-ride "
@@ -201,12 +202,13 @@ def read_response(
201202
"""Read ACK and Data packets from a UOSInterface.
202203
203204
:param expect_packets: How many packets including ACK to expect
204-
:param timeout_s: The maximum time this function will wait for data.
205+
:param timeout_s: The maximum time this function will wait for
206+
data.
205207
:return: COM Result object.
206208
:raises: UOSUnsupportedError if the interface hasn't been built
207-
correctly.
209+
correctly.
208210
:raises: UOSCommunicationError if there is a problem completing
209-
the action.
211+
the action.
210212
"""
211213
raise UOSUnsupportedError(
212214
"UOSInterfaces must over-ride "
@@ -219,9 +221,9 @@ def hard_reset(self) -> ComResult:
219221
220222
:return: COM Result object.
221223
:raises: UOSUnsupportedError if the interface hasn't been built
222-
correctly.
224+
correctly.
223225
:raises: UOSCommunicationError if there is a problem completing
224-
the action.
226+
the action.
225227
"""
226228
raise UOSUnsupportedError(
227229
"UOSInterfaces must over-ride "
@@ -233,9 +235,9 @@ def open(self):
233235
"""Abstract method for opening a connection to a UOSInterface.
234236
235237
:raises: UOSUnsupportedError if the interface hasn't been built
236-
correctly.
238+
correctly.
237239
:raises: UOSCommunicationError if there is a problem completing
238-
the action.
240+
the action.
239241
"""
240242
raise UOSUnsupportedError(
241243
"UOSInterfaces must over-ride " f"{UOSInterface.open.__name__} prototype."
@@ -246,9 +248,9 @@ def close(self):
246248
"""Abstract method for closing a connection to a UOSInterface.
247249
248250
:raises: UOSUnsupportedError if the interface hasn't been built
249-
correctly.
251+
correctly.
250252
:raises: UOSCommunicationError if there is a problem completing
251-
the action.
253+
the action.
252254
"""
253255
raise UOSUnsupportedError(
254256
"UOSInterfaces must over-ride " f"{UOSInterface.close.__name__} prototype."
@@ -260,7 +262,7 @@ def is_active(self) -> bool:
260262
261263
:return: Success boolean.
262264
:raises: UOSUnsupportedError if the interface hasn't been built
263-
correctly.
265+
correctly.
264266
"""
265267
raise UOSUnsupportedError(
266268
"UOSInterfaces must over-ride " f"{UOSInterface.close.__name__} prototype."
@@ -273,7 +275,7 @@ def enumerate_devices() -> list:
273275
274276
:return: A list of possible UOSInterfaces on the server.
275277
:raises: UOSUnsupportedError if the interface hasn't been built
276-
correctly.
278+
correctly.
277279
"""
278280
raise UOSUnsupportedError(
279281
"UOSInterfaces must over-ride "

uoshardware/api.py

+19-12
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def enumerate_system_devices( # dead: disable
2929
"""Iterate through all interfaces and locates available devices.
3030
3131
:param interface_filter: Interface enum to limit the search to a
32-
single interface type.
32+
single interface type.
3333
:return: A list of uosinterface objects.
3434
"""
3535
system_devices = []
@@ -44,7 +44,8 @@ def enumerate_system_devices( # dead: disable
4444
def get_device_definition(identity: str) -> Device | None:
4545
"""Look up the system config dictionary for the defined device mappings.
4646
47-
:param identity: String containing the lookup key of the device in the dictionary.
47+
:param identity: String containing the lookup key of the device in
48+
the dictionary.
4849
:return: Device Object or None if not found
4950
"""
5051
if identity is not None and hasattr(Devices, identity):
@@ -58,7 +59,8 @@ def get_device_definition(identity: str) -> Device | None:
5859
class UOSDevice: # dead: disable
5960
"""Class for high level object-orientated control of UOS devices.
6061
61-
:ivar identity: The type of device, this is must have a valid device in the config.
62+
:ivar identity: The type of device, this is must have a valid device
63+
in the config.
6264
:ivar address: Compliant connection string for identifying the
6365
device and interface.
6466
"""
@@ -165,10 +167,11 @@ def get_gpio_input(
165167
"""Read a GPIO pins level from device and returns the value.
166168
167169
:param pin: The numeric number of the pin as defined in the
168-
dictionary for that device.
169-
:param pull_up: Enable the internal pull-up resistor. Default is false.
170+
dictionary for that device.
171+
:param pull_up: Enable the internal pull-up resistor. Default is
172+
false.
170173
:param volatility: How volatile should the command be, use
171-
constants from uoshardware.
174+
constants from uoshardware.
172175
:return: ComResult object.
173176
"""
174177
result = self.__execute_instruction(
@@ -219,8 +222,9 @@ def reset_all_io(self, volatility=Persistence.RAM) -> ComResult:
219222
"""Execute the reset IO at the defined volatility level.
220223
221224
:param volatility: Where should the pins reset from, use
222-
constants from uoshardware.
223-
:return: ComResult object containing the result of the reset operation..
225+
constants from uoshardware.
226+
:return: ComResult object containing the result of the reset
227+
operation..
224228
"""
225229
return self.__execute_instruction(
226230
UOSFunctions.reset_all_io,
@@ -258,11 +262,13 @@ def __execute_instruction(
258262
"""Execute a generic UOS function and get the result.
259263
260264
:param function: The name of the function in the OOL.
261-
:param instruction_data: device_functions from the LUT, payload ect.
262-
:param retry: Allows the instruction to retry execution when fails.
265+
:param instruction_data: device_functions from the LUT, payload
266+
ect.
267+
:param retry: Allows the instruction to retry execution when
268+
fails.
263269
:return: ComResult object
264270
:raises: UOSUnsupportedError if function is not possible on the
265-
loaded device.
271+
loaded device.
266272
"""
267273
if (
268274
function.name not in self.__device.functions_enabled
@@ -373,7 +379,8 @@ def get_compatible_pins(self, function: UOSFunction) -> set:
373379
def get_functions_enabled(self) -> dict: # dead: disable
374380
"""Return functions enabled for the device.
375381
376-
:return: Dictionary of function names to list of Persistence levels.
382+
:return: Dictionary of function names to list of Persistence
383+
levels.
377384
"""
378385
return self.__device.functions_enabled
379386

uoshardware/interface/serial.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
class Serial(UOSInterface):
1717
"""Pyserial class that handles reading / writing to ports.
1818
19-
:ivar _device: Holds the pyserial device once opened. None if not opened.
19+
:ivar _device: Holds the pyserial device once opened. None if not
20+
opened.
2021
:ivar _connection: Holds the standard connection string
2122
'Interface'|'OS Connection String.
22-
:ivar _port: Holds the port class, none type if device not instantiated.
23-
:ivar _kwargs: Additional keyword arguments as defined in the documentation.
23+
:ivar _port: Holds the port class, none type if device not
24+
instantiated.
25+
:ivar _kwargs: Additional keyword arguments as defined in the
26+
documentation.
2427
"""
2528

2629
_device = None
@@ -100,9 +103,10 @@ def close(self):
100103
def execute_instruction(self, packet: NPCPacket):
101104
"""Build and execute a new instruction packet.
102105
103-
:param packet: A tuple containing the uint8 npc packet for the UOS instruction.
106+
:param packet: A tuple containing the uint8 npc packet for the
107+
UOS instruction.
104108
:return: Tuple containing a status boolean and index 0 and a
105-
result-set dict at index 1.
109+
result-set dict at index 1.
106110
"""
107111
if self._device is None:
108112
raise UOSCommunicationError(
@@ -124,7 +128,8 @@ def read_response(self, expect_packets: int, timeout_s: float):
124128
"""Read ACK and response packets from the serial device.
125129
126130
:param expect_packets: How many packets including ACK to expect.
127-
:param timeout_s: The maximum time this function will wait for data.
131+
:param timeout_s: The maximum time this function will wait for
132+
data.
128133
:return: ComResult object.
129134
"""
130135
if self._device is None:
@@ -173,7 +178,7 @@ def hard_reset(self):
173178
"""Manually drive the DTR line low to reset the device.
174179
175180
:return: Tuple containing a status boolean and index 0 and a
176-
result-set dict at index 1.
181+
result-set dict at index 1.
177182
"""
178183
if self._device is None:
179184
raise UOSCommunicationError("Connection must be open to hard reset device.")
@@ -206,7 +211,8 @@ def decode_and_capture(
206211
:param byte_index: The index of the last 'valid' byte found.
207212
:param byte_in: The current byte for inspection.
208213
:param packet: The current packet of validated bytes.
209-
:return: Tuple containing the updated byte index and updated packet.
214+
:return: Tuple containing the updated byte index and updated
215+
packet.
210216
"""
211217
if byte_index == -1: # start symbol
212218
if byte_in == b">":

0 commit comments

Comments
 (0)