From cea2d9bfc6beeca2d3a6616ffbfb29f03285f19b Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Sat, 29 Feb 2020 11:59:23 -0600 Subject: [PATCH 1/5] change get_firmware_version() function to firmware_version property --- adafruit_pn532/adafruit_pn532.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/adafruit_pn532/adafruit_pn532.py b/adafruit_pn532/adafruit_pn532.py index b0818bd..d797bc0 100644 --- a/adafruit_pn532/adafruit_pn532.py +++ b/adafruit_pn532/adafruit_pn532.py @@ -196,11 +196,11 @@ class PN532: try: self._wakeup() - self.get_firmware_version() # first time often fails, try 2ce + self.firmware_version # first time often fails, try 2ce return except (BusyError, RuntimeError): pass - self.get_firmware_version() + self.firmware_version def _read_data(self, count): # Read raw data from device, not including status bytes: @@ -317,7 +317,8 @@ class PN532: # Return response data. return response[2:] - def get_firmware_version(self): + @property + def firmware_version(self): """Call PN532 GetFirmwareVersion function and return a tuple with the IC, Ver, Rev, and Support values. """ From 474f2465083aa85d5e8cb2606deb7b894cdd058a Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Sat, 29 Feb 2020 12:08:24 -0600 Subject: [PATCH 2/5] update examples to use firmware_version property --- examples/pn532_readwrite_mifare.py | 2 +- examples/pn532_readwrite_ntag2xx.py | 2 +- examples/pn532_simpletest.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/pn532_readwrite_mifare.py b/examples/pn532_readwrite_mifare.py index 254ef3c..6d6ca7a 100644 --- a/examples/pn532_readwrite_mifare.py +++ b/examples/pn532_readwrite_mifare.py @@ -62,7 +62,7 @@ pn532 = PN532_I2C(i2c, debug=False) #uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100) #pn532 = PN532_UART(uart, debug=False) -ic, ver, rev, support = pn532.get_firmware_version() +ic, ver, rev, support = pn532.firmware_version print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev)) # Configure PN532 to communicate with MiFare cards diff --git a/examples/pn532_readwrite_ntag2xx.py b/examples/pn532_readwrite_ntag2xx.py index 2f51777..4c1e15e 100644 --- a/examples/pn532_readwrite_ntag2xx.py +++ b/examples/pn532_readwrite_ntag2xx.py @@ -58,7 +58,7 @@ pn532 = PN532_SPI(spi, cs_pin, debug=False) #uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100) #pn532 = PN532_UART(uart, debug=False) -ic, ver, rev, support = pn532.get_firmware_version() +ic, ver, rev, support = pn532.firmware_version print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev)) # Configure PN532 to communicate with MiFare cards diff --git a/examples/pn532_simpletest.py b/examples/pn532_simpletest.py index ab4b308..4eb5295 100644 --- a/examples/pn532_simpletest.py +++ b/examples/pn532_simpletest.py @@ -38,7 +38,7 @@ pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin) #uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100) #pn532 = PN532_UART(uart, debug=False) -ic, ver, rev, support = pn532.get_firmware_version() +ic, ver, rev, support = pn532.firmware_version print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev)) # Configure PN532 to communicate with MiFare cards From 0c287cd375a3a991c460e269248b6261864a75e1 Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Sat, 29 Feb 2020 12:37:06 -0600 Subject: [PATCH 3/5] pylint ignore statement effect in __init__() --- adafruit_pn532/adafruit_pn532.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_pn532/adafruit_pn532.py b/adafruit_pn532/adafruit_pn532.py index d797bc0..2c4b3b6 100644 --- a/adafruit_pn532/adafruit_pn532.py +++ b/adafruit_pn532/adafruit_pn532.py @@ -185,6 +185,7 @@ class BusyError(Exception): class PN532: """PN532 driver base, must be extended for I2C/SPI/UART interfacing""" + # noinspection PyStatementEffect def __init__(self, *, debug=False, reset=None): """Create an instance of the PN532 class """ @@ -196,7 +197,7 @@ class PN532: try: self._wakeup() - self.firmware_version # first time often fails, try 2ce + self.firmware_version # first time often fails, try 2ce return except (BusyError, RuntimeError): pass From 0e7d9b938d4b68ee6c775981704d3bd155ce0154 Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Sat, 29 Feb 2020 12:41:37 -0600 Subject: [PATCH 4/5] pylint disable pointless-statement in __init__() --- adafruit_pn532/adafruit_pn532.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_pn532/adafruit_pn532.py b/adafruit_pn532/adafruit_pn532.py index 2c4b3b6..b329b60 100644 --- a/adafruit_pn532/adafruit_pn532.py +++ b/adafruit_pn532/adafruit_pn532.py @@ -185,7 +185,7 @@ class BusyError(Exception): class PN532: """PN532 driver base, must be extended for I2C/SPI/UART interfacing""" - # noinspection PyStatementEffect + # pylint: disable=pointless-statement def __init__(self, *, debug=False, reset=None): """Create an instance of the PN532 class """ From 0b8cc7f076b416fcbcae79a72f15156b0fa42c47 Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Mon, 2 Mar 2020 19:41:07 -0600 Subject: [PATCH 5/5] re-enable pylint check. Try fix by setting result to variable. --- adafruit_pn532/adafruit_pn532.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/adafruit_pn532/adafruit_pn532.py b/adafruit_pn532/adafruit_pn532.py index b329b60..4eae888 100644 --- a/adafruit_pn532/adafruit_pn532.py +++ b/adafruit_pn532/adafruit_pn532.py @@ -185,7 +185,6 @@ class BusyError(Exception): class PN532: """PN532 driver base, must be extended for I2C/SPI/UART interfacing""" - # pylint: disable=pointless-statement def __init__(self, *, debug=False, reset=None): """Create an instance of the PN532 class """ @@ -197,11 +196,11 @@ class PN532: try: self._wakeup() - self.firmware_version # first time often fails, try 2ce + _ = self.firmware_version # first time often fails, try 2ce return except (BusyError, RuntimeError): pass - self.firmware_version + _ = self.firmware_version def _read_data(self, count): # Read raw data from device, not including status bytes: