Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit e173d55

Browse files
committed
Cleaning devices API to reduce visibility of low-level objects.
These objects are not required or useful for library usage.
1 parent c43b0ac commit e173d55

4 files changed

Lines changed: 24 additions & 20 deletions

File tree

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Version 0.4.0
88
this is for hash-ability. This change was required for 3.11
99
support due to the
1010
`dataclass changes <https://github.com/python/cpython/issues/88840>`_.
11+
* Device definitions are shifted into private modules within a
12+
devices packages. The intended API avoids having to be aware of this
13+
complexity.
1114

1215
Version 0.3.0
1316
-------------

uoshardware/abstractions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ class Device:
247247
"""Define an implemented UOS device dictionary."""
248248

249249
name: str
250-
versions: dict
251250
interfaces: list
252251
functions_enabled: dict
253252
digital_pins: dict = field(default_factory=dict)

uoshardware/devices/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Packages used to define Devices supported by the library."""
2+
from dataclasses import dataclass
3+
4+
from uoshardware.abstractions import Device
5+
from uoshardware.devices._arduino import _ARDUINO_NANO_3
6+
7+
8+
@dataclass(init=False, repr=False, frozen=True)
9+
class Devices:
10+
"""Names for supported hardware linking to the Device object used.
11+
12+
:cvar hwid_0: device: _ARDUINO_NANO_3
13+
:cvar arduino_nano: device: _ARDUINO_NANO_3
14+
:cvar arduino_uno: device: _ARDUINO_NANO_3
15+
"""
16+
17+
# Lookup constants linking devices to importable names
18+
hwid_0: Device = _ARDUINO_NANO_3
19+
arduino_nano: Device = _ARDUINO_NANO_3
20+
arduino_uno: Device = _ARDUINO_NANO_3
Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
"""Module defining supported hardware definitions."""
2-
from dataclasses import dataclass
3-
1+
"""Module contains definitions for arduino devices."""
42
from uoshardware import Persistence
53
from uoshardware.abstractions import Device, Pin, UOSFunctions
64
from uoshardware.interface import Interface
75

86
_ARDUINO_NANO_3 = Device(
97
name="Arduino Nano 3",
10-
versions={},
118
interfaces=[Interface.STUB, Interface.SERIAL],
129
functions_enabled={
1310
UOSFunctions.set_gpio_output.name: [Persistence.NONE],
@@ -109,18 +106,3 @@
109106
},
110107
aux_params={"default_baudrate": 115200},
111108
)
112-
113-
114-
@dataclass(init=False, repr=False, frozen=True)
115-
class Devices:
116-
"""Names for supported hardware linking to the Device object used.
117-
118-
:cvar hwid_0: device: _ARDUINO_NANO_3
119-
:cvar arduino_nano: device: _ARDUINO_NANO_3
120-
:cvar arduino_uno: device: _ARDUINO_NANO_3
121-
"""
122-
123-
# Lookup constants linking devices to importable names
124-
hwid_0: Device = _ARDUINO_NANO_3
125-
arduino_nano: Device = _ARDUINO_NANO_3
126-
arduino_uno: Device = _ARDUINO_NANO_3

0 commit comments

Comments
 (0)