Skip to content

Commit 36ac4bc

Browse files
committed
isort and flake8 fixes
1 parent 7e5d08e commit 36ac4bc

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

gpio_expander.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
# SPDX-FileCopyrightText: Copyright (c) 2022 Gabriele Pongelli
33
#
44
# SPDX-License-Identifier: MIT
5+
56
"""
6-
`gpio_expander`
7+
8+
`gpio_expander`.
9+
710
================================================================================
811
912
CircuitPython helper library for gpio expanders (Texas Instrument PCA95xx and TCA95xx chips).
@@ -35,25 +38,17 @@
3538

3639
# imports
3740
try:
38-
import typing # pylint: disable=unused-import
3941
from busio import I2C
4042
except ImportError:
4143
pass
4244

4345
__version__ = "0.0.0"
4446
__repo__ = "https://github.com/gpongelli/CircuitPython_gpio_expander.git"
4547

46-
from micropython import const
4748
import adafruit_bus_device.i2c_device as i2cdevice
48-
4949
from adafruit_register.i2c_bit import ROBit, RWBit
5050
from adafruit_register.i2c_bits import ROBits, RWBits
51-
52-
try:
53-
from typing import Optional, Type, NoReturn
54-
from circuitpython_typing.device_drivers import I2CDeviceDriver
55-
except ImportError:
56-
pass
51+
from micropython import const
5752

5853
# For the PCA 953X and 955X series, the chips with 8 GPIO's have these port numbers
5954
# The chips with 16 GPIO's have the first port for each type at double these numbers
@@ -80,7 +75,7 @@ def _get_registry_params(value, x):
8075
return _name, _reg_address_multiplier, _adder, _idx
8176

8277

83-
class MetaGPIOExpander(type):
78+
class _MetaGPIOExpander(type):
8479
def __new__(mcs, clsname, bases, dct, *args, **kwargs):
8580
result_dct = {}
8681

@@ -122,11 +117,11 @@ def __new__(mcs, clsname, bases, dct, *args, **kwargs):
122117
prop_name = f"C{_name}{_idx}"
123118
result_dct[prop_name] = _cfg_reg
124119

125-
inst = super(MetaGPIOExpander, mcs).__new__(mcs, clsname, bases, result_dct)
120+
inst = super(_MetaGPIOExpander, mcs).__new__(mcs, clsname, bases, result_dct)
126121
return inst
127122

128123

129-
class BaseGPIOExpander(metaclass=MetaGPIOExpander):
124+
class _BaseGPIOExpander(metaclass=_MetaGPIOExpander):
130125
def __init__(self, i2c_bus: I2C, address: int, **kwargs) -> None:
131126
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
132127

@@ -135,26 +130,38 @@ def max_gpios(self):
135130

136131

137132
# PCA series
138-
class PCA9534(BaseGPIOExpander):
133+
class PCA9534(_BaseGPIOExpander):
134+
"""PCA9534 8-Bit I2C I/O Expander."""
135+
139136
_NUM_GPIO = 8
140137

141138

142-
class PCA9535(BaseGPIOExpander):
139+
class PCA9535(_BaseGPIOExpander):
140+
"""PCA9535 16-Bit I2C I/O Expander."""
141+
143142
_NUM_GPIO = 16
144143

145144

146-
class PCA9555(BaseGPIOExpander):
145+
class PCA9555(_BaseGPIOExpander):
146+
"""PCA9555 16-Bit I2C I/O Expander."""
147+
147148
_NUM_GPIO = 16
148149

149150

150151
# TCA series
151-
class TCA9534(BaseGPIOExpander):
152+
class TCA9534(_BaseGPIOExpander):
153+
"""TCA9534 Low-Voltage 8-Bit I2C I/O Expander."""
154+
152155
_NUM_GPIO = 8
153156

154157

155-
class TCA9535(BaseGPIOExpander):
158+
class TCA9535(_BaseGPIOExpander):
159+
"""TCA9535 Low-Voltage 16-Bit I2C I/O Expander."""
160+
156161
_NUM_GPIO = 16
157162

158163

159-
class TCA9555(BaseGPIOExpander):
164+
class TCA9555(_BaseGPIOExpander):
165+
"""TCA9555 Low-Voltage 16-Bit I2C I/O Expander."""
166+
160167
_NUM_GPIO = 16

0 commit comments

Comments
 (0)