Skip to content

Commit cd4669d

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

File tree

4 files changed

+51
-41
lines changed

4 files changed

+51
-41
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

+20-14
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,9 +59,9 @@ 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 address: Compliant connection string for identifying the
63-
device and interface.
62+
:ivar identity: The type of device, this is must have a valid device
63+
in the config. :ivar address: Compliant connection string for
64+
identifying the device and interface.
6465
"""
6566

6667
__device: Device # Device definitions as parsed from a compatible ini.
@@ -165,10 +166,11 @@ def get_gpio_input(
165166
"""Read a GPIO pins level from device and returns the value.
166167
167168
: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.
169+
dictionary for that device.
170+
:param pull_up: Enable the internal pull-up resistor. Default is
171+
false.
170172
:param volatility: How volatile should the command be, use
171-
constants from uoshardware.
173+
constants from uoshardware.
172174
:return: ComResult object.
173175
"""
174176
result = self.__execute_instruction(
@@ -219,8 +221,9 @@ def reset_all_io(self, volatility=Persistence.RAM) -> ComResult:
219221
"""Execute the reset IO at the defined volatility level.
220222
221223
:param volatility: Where should the pins reset from, use
222-
constants from uoshardware.
223-
:return: ComResult object containing the result of the reset operation..
224+
constants from uoshardware.
225+
:return: ComResult object containing the result of the reset
226+
operation..
224227
"""
225228
return self.__execute_instruction(
226229
UOSFunctions.reset_all_io,
@@ -258,11 +261,13 @@ def __execute_instruction(
258261
"""Execute a generic UOS function and get the result.
259262
260263
: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.
264+
:param instruction_data: device_functions from the LUT, payload
265+
ect.
266+
:param retry: Allows the instruction to retry execution when
267+
fails.
263268
:return: ComResult object
264269
:raises: UOSUnsupportedError if function is not possible on the
265-
loaded device.
270+
loaded device.
266271
"""
267272
if (
268273
function.name not in self.__device.functions_enabled
@@ -373,7 +378,8 @@ def get_compatible_pins(self, function: UOSFunction) -> set:
373378
def get_functions_enabled(self) -> dict: # dead: disable
374379
"""Return functions enabled for the device.
375380
376-
:return: Dictionary of function names to list of Persistence levels.
381+
:return: Dictionary of function names to list of Persistence
382+
levels.
377383
"""
378384
return self.__device.functions_enabled
379385

uoshardware/devices/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
class Devices:
1010
"""Names for supported hardware linking to the Device object used.
1111
12-
:cvar hwid_0: device: _ARDUINO_NANO_3
13-
:cvar arduino_nano: device: _ARDUINO_NANO_3
14-
:cvar arduino_uno: device: _ARDUINO_NANO_3
12+
:cvar hwid_0: device: _ARDUINO_NANO_3 :cvar arduino_nano: device:
13+
_ARDUINO_NANO_3 :cvar arduino_uno: device: _ARDUINO_NANO_3
1514
"""
1615

1716
# Lookup constants linking devices to importable names

uoshardware/interface/serial.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
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.
20-
:ivar _connection: Holds the standard connection string
21-
'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.
19+
:ivar _device: Holds the pyserial device once opened. None if not
20+
opened. :ivar _connection: Holds the standard connection string
21+
'Interface'|'OS Connection String. :ivar _port: Holds the port
22+
class, none type if device not instantiated. :ivar _kwargs:
23+
Additional keyword arguments as defined in the documentation.
2424
"""
2525

2626
_device = None
@@ -100,9 +100,10 @@ def close(self):
100100
def execute_instruction(self, packet: NPCPacket):
101101
"""Build and execute a new instruction packet.
102102
103-
:param packet: A tuple containing the uint8 npc packet for the UOS instruction.
103+
:param packet: A tuple containing the uint8 npc packet for the
104+
UOS instruction.
104105
:return: Tuple containing a status boolean and index 0 and a
105-
result-set dict at index 1.
106+
result-set dict at index 1.
106107
"""
107108
if self._device is None:
108109
raise UOSCommunicationError(
@@ -124,7 +125,8 @@ def read_response(self, expect_packets: int, timeout_s: float):
124125
"""Read ACK and response packets from the serial device.
125126
126127
:param expect_packets: How many packets including ACK to expect.
127-
:param timeout_s: The maximum time this function will wait for data.
128+
:param timeout_s: The maximum time this function will wait for
129+
data.
128130
:return: ComResult object.
129131
"""
130132
if self._device is None:
@@ -173,7 +175,7 @@ def hard_reset(self):
173175
"""Manually drive the DTR line low to reset the device.
174176
175177
:return: Tuple containing a status boolean and index 0 and a
176-
result-set dict at index 1.
178+
result-set dict at index 1.
177179
"""
178180
if self._device is None:
179181
raise UOSCommunicationError("Connection must be open to hard reset device.")
@@ -206,7 +208,8 @@ def decode_and_capture(
206208
:param byte_index: The index of the last 'valid' byte found.
207209
:param byte_in: The current byte for inspection.
208210
:param packet: The current packet of validated bytes.
209-
:return: Tuple containing the updated byte index and updated packet.
211+
:return: Tuple containing the updated byte index and updated
212+
packet.
210213
"""
211214
if byte_index == -1: # start symbol
212215
if byte_in == b">":

0 commit comments

Comments
 (0)