Skip to content

Commit 8f6c8b3

Browse files
authored
Merge pull request #7 from tekktrik/dev/add-driver-class
Add I2CDeviceDriver duck type
2 parents 26dfc45 + 8accb78 commit 8f6c8b3

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney
2+
# SPDX-License-Identifier: MIT
3+
"""
4+
`circuitpython_typing.device_drivers`
5+
================================================================================
6+
7+
Type annotation definitions for device drivers. Used for `adafruit_register`.
8+
9+
* Author(s): Alec Delaney
10+
"""
11+
12+
from adafruit_bus_device import I2CDevice
13+
14+
# # Protocol was introduced in Python 3.8.
15+
try:
16+
from typing import Protocol
17+
except ImportError:
18+
from typing_extensions import Protocol
19+
20+
21+
# pylint: disable=too-few-public-methods
22+
class I2CDeviceDriver(Protocol):
23+
"""Describes classes that are drivers utilizing `I2CDevice`"""
24+
25+
i2c_device: I2CDevice

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
# SPDX-License-Identifier: MIT
55

66
typing_extensions; python_version <= '3.7'
7+
adafruit-circuitpython-busdevice

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@
3939
# Author details
4040
author="Adafruit Industries",
4141
author_email="[email protected]",
42-
install_requires=["typing_extensions; python_version <= '3.7'"],
42+
install_requires=[
43+
"typing_extensions; python_version <= '3.7'",
44+
"adafruit-circuitpython-busdevice",
45+
],
4346
# Choose your license
4447
license="MIT",
4548
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers

0 commit comments

Comments
 (0)