From 4ba38a58ea6e3f38a70be76a4155fd943fca45dd Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 25 Jul 2020 20:00:04 -0500 Subject: [PATCH 1/2] i2c_device: adjust for removal of stop=, compatibly This version prints (to the serial console) a message about the deprecation. Then we can remove it *HERE* in a future release. --- adafruit_bus_device/i2c_device.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/adafruit_bus_device/i2c_device.py b/adafruit_bus_device/i2c_device.py index 0e2bd17..5ae5483 100644 --- a/adafruit_bus_device/i2c_device.py +++ b/adafruit_bus_device/i2c_device.py @@ -85,7 +85,7 @@ def readinto(self, buf, *, start=0, end=None): end = len(buf) self.i2c.readfrom_into(self.device_address, buf, start=start, end=end) - def write(self, buf, *, start=0, end=None, stop=True): + def write(self, buf, *, start=0, end=None, stop=None): """ Write the bytes from ``buffer`` to the device. Transmits a stop bit if ``stop`` is set. @@ -97,11 +97,12 @@ def write(self, buf, *, start=0, end=None, stop=True): :param bytearray buffer: buffer containing the bytes to write :param int start: Index to start writing from :param int end: Index to read up to but not include; if None, use ``len(buf)`` - :param bool stop: If true, output an I2C stop condition after the buffer is written """ + if stop is not None: + print("Warning: deprecated stop= argument specified. Deprecated. Will be removed in a future release and act as stop=True") if end is None: end = len(buf) - self.i2c.writeto(self.device_address, buf, start=start, end=end, stop=stop) + self.i2c.writeto(self.device_address, buf, start=start, end=end) # pylint: disable-msg=too-many-arguments def write_then_readinto( From 4e7f5649f9348e73e468a3116b904c7a0031edc9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 25 Jul 2020 20:24:32 -0500 Subject: [PATCH 2/2] reformat for black, pylint --- adafruit_bus_device/i2c_device.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adafruit_bus_device/i2c_device.py b/adafruit_bus_device/i2c_device.py index 5ae5483..6100c1c 100644 --- a/adafruit_bus_device/i2c_device.py +++ b/adafruit_bus_device/i2c_device.py @@ -99,7 +99,10 @@ def write(self, buf, *, start=0, end=None, stop=None): :param int end: Index to read up to but not include; if None, use ``len(buf)`` """ if stop is not None: - print("Warning: deprecated stop= argument specified. Deprecated. Will be removed in a future release and act as stop=True") + print( + "Warning: deprecated stop= argument specified.\n" + "Will be removed in a future release and act as stop=True" + ) if end is None: end = len(buf) self.i2c.writeto(self.device_address, buf, start=start, end=end)