Skip to content

Commit ddeb4a4

Browse files
committed
libs/driver: Fix code bugs detected by ruff tool.
Signed-off-by: imliubo <[email protected]>
1 parent 21cb27c commit ddeb4a4

File tree

6 files changed

+8
-4
lines changed

6 files changed

+8
-4
lines changed

m5stack/libs/driver/mfrc522/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def pcd_communicate_with_picc(
301301
):
302302
_validBits = 0
303303

304-
txLastBits = validBits if validBits != None else 0
304+
txLastBits = validBits if validBits is not None else 0
305305
bitFraming = (rxAlign << 4) + txLastBits
306306

307307
self.pcd_write_register(COMMAND_REG, PCD_IDLE)
@@ -345,7 +345,7 @@ def pcd_communicate_with_picc(
345345
backData = bytearray(l)
346346
self.pcd_read_bytes(FIFODATA_REG, backData, rxAlign)
347347
_validBits = self.pcd_read_register(CONTROL_REG) & 0x07
348-
if validBits != None:
348+
if validBits is not None:
349349
validBits = _validBits
350350

351351
# print("backData:", backData)
@@ -1072,7 +1072,7 @@ def mifare_open_uid_backdoor(self, logErrors=False) -> bool:
10721072

10731073
validBits = 8
10741074
status, response1, validBits = self.pcd_transceive_data(
1075-
bytearray([0x43]), validBits=validBits, rxAlign=0, rxAlign=False
1075+
bytearray([0x43]), validBits=validBits, rxAlign=0, checkCRC=False
10761076
)
10771077
if response1:
10781078
response[: len(response1)] = response1

m5stack/libs/driver/mfrc522/cmd.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from micropython import const
12
# MFRC522 commands. Described in chapter 10 of the datasheet.
23

34
# no action, cancels current command execution

m5stack/libs/driver/mfrc522/reg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from micropython import const
12
# MFRC522 registers. Described in chapter 9 of the datasheet.
23
# Page 0: Command and status
34

m5stack/libs/driver/rotary/rotary.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# https://github.com/MikeTeachman/micropython-rotary
99

1010
import micropython
11+
from micropython import const
1112

1213
_DIR_CW = const(0x10) # Clockwise step
1314
_DIR_CCW = const(0x20) # Counter-clockwise step

m5stack/libs/module/dual_kmeter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from micropython import const
12
from .mbus import i2c1
23
import struct
34

m5stack/libs/unit/lorawan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class LoRaWANUnit(LoRaWAN_470):
66
def __init__(self, port):
7-
super(LoRaWAN, self).__init__(tx=port[1], rx=port[0])
7+
super(LoRaWAN_470, self).__init__(tx=port[1], rx=port[0])
88
self.tx = port[1]
99
self.rx = port[0]
1010

0 commit comments

Comments
 (0)