The following issues were found
ports/stm32/boards/NUCLEO_WB55/rfcore_firmware.py
41 issues
Line: 65
Column: 1
# from your application code.
import struct, os
import machine, stm
from micropython import const
_OGF_VENDOR = const(0x3F)
_OCF_FUS_GET_STATE = const(0x52)
Reported by Pylint.
Line: 65
Column: 1
# from your application code.
import struct, os
import machine, stm
from micropython import const
_OGF_VENDOR = const(0x3F)
_OCF_FUS_GET_STATE = const(0x52)
Reported by Pylint.
Line: 66
Column: 1
import struct, os
import machine, stm
from micropython import const
_OGF_VENDOR = const(0x3F)
_OCF_FUS_GET_STATE = const(0x52)
_OCF_FUS_FW_UPGRADE = const(0x54)
Reported by Pylint.
Line: 1
Column: 1
# This file is part of the MicroPython project, http://micropython.org/
#
# The MIT License (MIT)
#
# Copyright (c) 2020 Damien P. George
# Copyright (c) 2020 Jim Mussared
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Reported by Pylint.
Line: 38
Column: 1
# To perform a firmware update:
#
# 1. Generate "obfuscated" binary images using rfcore_makefirmware.py
# ./boards/NUCLEO_WB55/rfcore_makefirmware.py ~/src/github.com/STMicroelectronics/STM32CubeWB/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x/ /tmp
# This will generate /tmp/{fus_102,fus_110,ws_ble_hci}.bin
#
# 2. Copy required files to the device filesystem.
# In general, it's always safe to copy all three files and the updater will
# figure out what needs to be done. This is the recommended option.
Reported by Pylint.
Line: 64
Column: 1
# You can use the built-in stm.rfcore_fw_version() to query the installed version
# from your application code.
import struct, os
import machine, stm
from micropython import const
_OGF_VENDOR = const(0x3F)
Reported by Pylint.
Line: 65
Column: 1
# from your application code.
import struct, os
import machine, stm
from micropython import const
_OGF_VENDOR = const(0x3F)
_OCF_FUS_GET_STATE = const(0x52)
Reported by Pylint.
Line: 190
Column: 1
_INSTALLING_WS_GET_STATE_TIMEOUT = const(6000)
def log(msg, *args, **kwargs):
print("[rfcore update]", msg.format(*args, **kwargs))
class _Flash:
_FLASH_KEY1 = 0x45670123
Reported by Pylint.
Line: 202
Column: 5
_FLASH_CR_LOCK_MASK = 1 << 31
_FLASH_SR_BSY_MASK = 1 << 16
def wait_not_busy(self):
while machine.mem32[stm.FLASH + stm.FLASH_SR] & _Flash._FLASH_SR_BSY_MASK:
machine.idle()
def unlock(self):
if machine.mem32[stm.FLASH + stm.FLASH_CR] & _Flash._FLASH_CR_LOCK_MASK:
Reported by Pylint.
Line: 202
Column: 5
_FLASH_CR_LOCK_MASK = 1 << 31
_FLASH_SR_BSY_MASK = 1 << 16
def wait_not_busy(self):
while machine.mem32[stm.FLASH + stm.FLASH_SR] & _Flash._FLASH_SR_BSY_MASK:
machine.idle()
def unlock(self):
if machine.mem32[stm.FLASH + stm.FLASH_CR] & _Flash._FLASH_CR_LOCK_MASK:
Reported by Pylint.
ports/stm32/boards/NUCLEO_WB55/rfcore_debug.py
41 issues
Line: 37
Column: 1
# The `stm` module provides some helper functions to access rfcore functionality.
# See rfcore_firmware.py for more information.
from machine import mem8, mem16, mem32
import stm
SRAM2A_BASE = const(0x2003_0000)
# for vendor OGF
Reported by Pylint.
Line: 38
Column: 1
# See rfcore_firmware.py for more information.
from machine import mem8, mem16, mem32
import stm
SRAM2A_BASE = const(0x2003_0000)
# for vendor OGF
OGF_VENDOR = const(0x3F)
Reported by Pylint.
Line: 40
Column: 15
from machine import mem8, mem16, mem32
import stm
SRAM2A_BASE = const(0x2003_0000)
# for vendor OGF
OGF_VENDOR = const(0x3F)
OCF_FUS_GET_STATE = const(0x52)
OCF_FUS_FW_UPGRADE = const(0x54)
Reported by Pylint.
Line: 43
Column: 14
SRAM2A_BASE = const(0x2003_0000)
# for vendor OGF
OGF_VENDOR = const(0x3F)
OCF_FUS_GET_STATE = const(0x52)
OCF_FUS_FW_UPGRADE = const(0x54)
OCF_FUS_FW_DELETE = const(0x55)
OCF_FUS_START_WS = const(0x5A)
OCF_BLE_INIT = const(0x66)
Reported by Pylint.
Line: 44
Column: 21
# for vendor OGF
OGF_VENDOR = const(0x3F)
OCF_FUS_GET_STATE = const(0x52)
OCF_FUS_FW_UPGRADE = const(0x54)
OCF_FUS_FW_DELETE = const(0x55)
OCF_FUS_START_WS = const(0x5A)
OCF_BLE_INIT = const(0x66)
Reported by Pylint.
Line: 45
Column: 22
# for vendor OGF
OGF_VENDOR = const(0x3F)
OCF_FUS_GET_STATE = const(0x52)
OCF_FUS_FW_UPGRADE = const(0x54)
OCF_FUS_FW_DELETE = const(0x55)
OCF_FUS_START_WS = const(0x5A)
OCF_BLE_INIT = const(0x66)
TABLE_DEVICE_INFO = const(0)
Reported by Pylint.
Line: 46
Column: 21
OGF_VENDOR = const(0x3F)
OCF_FUS_GET_STATE = const(0x52)
OCF_FUS_FW_UPGRADE = const(0x54)
OCF_FUS_FW_DELETE = const(0x55)
OCF_FUS_START_WS = const(0x5A)
OCF_BLE_INIT = const(0x66)
TABLE_DEVICE_INFO = const(0)
TABLE_BLE = const(1)
Reported by Pylint.
Line: 47
Column: 20
OCF_FUS_GET_STATE = const(0x52)
OCF_FUS_FW_UPGRADE = const(0x54)
OCF_FUS_FW_DELETE = const(0x55)
OCF_FUS_START_WS = const(0x5A)
OCF_BLE_INIT = const(0x66)
TABLE_DEVICE_INFO = const(0)
TABLE_BLE = const(1)
TABLE_SYS = const(3)
Reported by Pylint.
Line: 48
Column: 16
OCF_FUS_FW_UPGRADE = const(0x54)
OCF_FUS_FW_DELETE = const(0x55)
OCF_FUS_START_WS = const(0x5A)
OCF_BLE_INIT = const(0x66)
TABLE_DEVICE_INFO = const(0)
TABLE_BLE = const(1)
TABLE_SYS = const(3)
TABLE_MEM_MANAGER = const(4)
Reported by Pylint.
Line: 50
Column: 21
OCF_FUS_START_WS = const(0x5A)
OCF_BLE_INIT = const(0x66)
TABLE_DEVICE_INFO = const(0)
TABLE_BLE = const(1)
TABLE_SYS = const(3)
TABLE_MEM_MANAGER = const(4)
CHANNEL_BLE = const(1)
Reported by Pylint.
tests/basics/unpack1.py
40 issues
Line: 1
Column: 1
# unpack sequences
a, = 1, ; print(a)
a, b = 2, 3 ; print(a, b)
a, b, c = 1, 2, 3; print(a, b, c)
a, = range(1); print(a)
a, b = range(2); print(a, b)
a, b, c = range(3); print(a, b, c)
Reported by Pylint.
Line: 3
Column: 15
# unpack sequences
a, = 1, ; print(a)
a, b = 2, 3 ; print(a, b)
a, b, c = 1, 2, 3; print(a, b, c)
a, = range(1); print(a)
a, b = range(2); print(a, b)
a, b, c = range(3); print(a, b, c)
Reported by Pylint.
Line: 4
Column: 15
# unpack sequences
a, = 1, ; print(a)
a, b = 2, 3 ; print(a, b)
a, b, c = 1, 2, 3; print(a, b, c)
a, = range(1); print(a)
a, b = range(2); print(a, b)
a, b, c = range(3); print(a, b, c)
Reported by Pylint.
Line: 5
Column: 20
a, = 1, ; print(a)
a, b = 2, 3 ; print(a, b)
a, b, c = 1, 2, 3; print(a, b, c)
a, = range(1); print(a)
a, b = range(2); print(a, b)
a, b, c = range(3); print(a, b, c)
Reported by Pylint.
Line: 7
Column: 16
a, b = 2, 3 ; print(a, b)
a, b, c = 1, 2, 3; print(a, b, c)
a, = range(1); print(a)
a, b = range(2); print(a, b)
a, b, c = range(3); print(a, b, c)
(a) = range(1); print(a)
(a,) = range(1); print(a)
Reported by Pylint.
Line: 8
Column: 18
a, b, c = 1, 2, 3; print(a, b, c)
a, = range(1); print(a)
a, b = range(2); print(a, b)
a, b, c = range(3); print(a, b, c)
(a) = range(1); print(a)
(a,) = range(1); print(a)
(a, b) = range(2); print(a, b)
Reported by Pylint.
Line: 9
Column: 21
a, = range(1); print(a)
a, b = range(2); print(a, b)
a, b, c = range(3); print(a, b, c)
(a) = range(1); print(a)
(a,) = range(1); print(a)
(a, b) = range(2); print(a, b)
(a, b, c) = range(3); print(a, b, c)
Reported by Pylint.
Line: 11
Column: 17
a, b = range(2); print(a, b)
a, b, c = range(3); print(a, b, c)
(a) = range(1); print(a)
(a,) = range(1); print(a)
(a, b) = range(2); print(a, b)
(a, b, c) = range(3); print(a, b, c)
(a, (b, c)) = [-1, range(2)]; print(a, b, c)
Reported by Pylint.
Line: 12
Column: 18
a, b, c = range(3); print(a, b, c)
(a) = range(1); print(a)
(a,) = range(1); print(a)
(a, b) = range(2); print(a, b)
(a, b, c) = range(3); print(a, b, c)
(a, (b, c)) = [-1, range(2)]; print(a, b, c)
# lists
Reported by Pylint.
Line: 13
Column: 20
(a) = range(1); print(a)
(a,) = range(1); print(a)
(a, b) = range(2); print(a, b)
(a, b, c) = range(3); print(a, b, c)
(a, (b, c)) = [-1, range(2)]; print(a, b, c)
# lists
Reported by Pylint.
tests/multi_bluetooth/perf_l2cap.py
40 issues
Line: 3
Column: 1
# Send L2CAP data as fast as possible and time it.
from micropython import const
import time, machine, bluetooth, random
if not hasattr(bluetooth.BLE, "l2cap_connect"):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 4
Column: 1
# Send L2CAP data as fast as possible and time it.
from micropython import const
import time, machine, bluetooth, random
if not hasattr(bluetooth.BLE, "l2cap_connect"):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 4
Column: 1
# Send L2CAP data as fast as possible and time it.
from micropython import const
import time, machine, bluetooth, random
if not hasattr(bluetooth.BLE, "l2cap_connect"):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 53
Column: 10
def wait_for_event(event, timeout_ms):
t0 = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), t0) < timeout_ms:
if event in waiting_events:
return waiting_events.pop(event)
machine.idle()
raise ValueError("Timeout waiting for {}".format(event))
Reported by Pylint.
Line: 54
Column: 27
def wait_for_event(event, timeout_ms):
t0 = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), t0) < timeout_ms:
if event in waiting_events:
return waiting_events.pop(event)
machine.idle()
raise ValueError("Timeout waiting for {}".format(event))
Reported by Pylint.
Line: 54
Column: 11
def wait_for_event(event, timeout_ms):
t0 = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), t0) < timeout_ms:
if event in waiting_events:
return waiting_events.pop(event)
machine.idle()
raise ValueError("Timeout waiting for {}".format(event))
Reported by Pylint.
Line: 79
Column: 32
while recv_bytes < expected_bytes:
wait_for_event(_IRQ_L2CAP_RECV, TIMEOUT_MS)
if not ticks_first_byte:
ticks_first_byte = time.ticks_ms()
while True:
n = ble.l2cap_recvinto(conn_handle, cid, buf)
if n == 0:
break
recv_bytes += n
Reported by Pylint.
Line: 88
Column: 17
for i in range(n):
if buf[i] == random.randint(0, 255):
recv_correct += 1
ticks_end = time.ticks_ms()
return recv_bytes, recv_correct, time.ticks_diff(ticks_end, ticks_first_byte)
# Acting in peripheral role.
def instance0():
Reported by Pylint.
Line: 89
Column: 38
if buf[i] == random.randint(0, 255):
recv_correct += 1
ticks_end = time.ticks_ms()
return recv_bytes, recv_correct, time.ticks_diff(ticks_end, ticks_first_byte)
# Acting in peripheral role.
def instance0():
multitest.globals(BDADDR=ble.config("mac"))
Reported by Pylint.
Line: 94
Column: 5
# Acting in peripheral role.
def instance0():
multitest.globals(BDADDR=ble.config("mac"))
ble.gap_advertise(20_000, b"\x02\x01\x06\x04\xffMPY")
multitest.next()
try:
# Wait for central to connect to us.
conn_handle = wait_for_event(_IRQ_CENTRAL_CONNECT, TIMEOUT_MS)
Reported by Pylint.
tests/multi_bluetooth/ble_subscribe.py
39 issues
Line: 3
Column: 1
# Test for sending notifications to subscribed clients.
from micropython import const
import time, machine, bluetooth
TIMEOUT_MS = 5000
_IRQ_CENTRAL_CONNECT = const(1)
_IRQ_CENTRAL_DISCONNECT = const(2)
Reported by Pylint.
Line: 4
Column: 1
# Test for sending notifications to subscribed clients.
from micropython import const
import time, machine, bluetooth
TIMEOUT_MS = 5000
_IRQ_CENTRAL_CONNECT = const(1)
_IRQ_CENTRAL_DISCONNECT = const(2)
Reported by Pylint.
Line: 4
Column: 1
# Test for sending notifications to subscribed clients.
from micropython import const
import time, machine, bluetooth
TIMEOUT_MS = 5000
_IRQ_CENTRAL_CONNECT = const(1)
_IRQ_CENTRAL_DISCONNECT = const(2)
Reported by Pylint.
Line: 87
Column: 10
def wait_for_event(event, timeout_ms):
t0 = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), t0) < timeout_ms:
if event in waiting_events:
return waiting_events.pop(event)
machine.idle()
raise ValueError("Timeout waiting for {}".format(event))
Reported by Pylint.
Line: 88
Column: 27
def wait_for_event(event, timeout_ms):
t0 = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), t0) < timeout_ms:
if event in waiting_events:
return waiting_events.pop(event)
machine.idle()
raise ValueError("Timeout waiting for {}".format(event))
Reported by Pylint.
Line: 88
Column: 11
def wait_for_event(event, timeout_ms):
t0 = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), t0) < timeout_ms:
if event in waiting_events:
return waiting_events.pop(event)
machine.idle()
raise ValueError("Timeout waiting for {}".format(event))
Reported by Pylint.
Line: 97
Column: 5
# Acting in peripheral role.
def instance0():
multitest.globals(BDADDR=ble.config("mac"))
((char_handle,),) = ble.gatts_register_services(SERVICES)
print("gap_advertise")
ble.gap_advertise(20_000, b"\x02\x01\x06\x04\xffMPY") # \x04\x09MPY
multitest.next()
try:
Reported by Pylint.
Line: 101
Column: 5
((char_handle,),) = ble.gatts_register_services(SERVICES)
print("gap_advertise")
ble.gap_advertise(20_000, b"\x02\x01\x06\x04\xffMPY") # \x04\x09MPY
multitest.next()
try:
# Write initial characteristic value (will be read by client).
ble.gatts_write(char_handle, "periph0") ###
# Wait for central to connect to us.
Reported by Pylint.
Line: 115
Column: 9
print("sync A")
# This should be local-only.
ble.gatts_write(char_handle, "periph1")
time.sleep_ms(100)
# Update local-only, then force notify.
ble.gatts_write(char_handle, "periph2")
ble.gatts_notify(conn_handle, char_handle) ###
time.sleep_ms(100)
# Update local and notify subscribers. No notification should be sent.
Reported by Pylint.
Line: 119
Column: 9
# Update local-only, then force notify.
ble.gatts_write(char_handle, "periph2")
ble.gatts_notify(conn_handle, char_handle) ###
time.sleep_ms(100)
# Update local and notify subscribers. No notification should be sent.
ble.gatts_write(char_handle, "periph3", True)
time.sleep_ms(100)
multitest.broadcast("A")
Reported by Pylint.
tools/makemanifest.py
39 issues
Line: 70
Column: 13
# Applies to includes and input files.
prev_cwd = os.getcwd()
os.chdir(os.path.dirname(manifest))
exec(f.read(), globals(), {"options": IncludeOptions(**kwargs)})
os.chdir(prev_cwd)
def freeze(path, script=None, opt=0):
"""Freeze the input, automatically determining its type. A .py script
Reported by Pylint.
Line: 70
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
# Applies to includes and input files.
prev_cwd = os.getcwd()
os.chdir(os.path.dirname(manifest))
exec(f.read(), globals(), {"options": IncludeOptions(**kwargs)})
os.chdir(prev_cwd)
def freeze(path, script=None, opt=0):
"""Freeze the input, automatically determining its type. A .py script
Reported by Bandit.
Line: 181
Column: 13
return stat.st_mtime
except OSError:
if default is None:
raise FreezeError("cannot stat {}".format(path))
return default
def get_timestamp_newest(path):
ts_newest = 0
Reported by Pylint.
Line: 187
Column: 18
def get_timestamp_newest(path):
ts_newest = 0
for dirpath, dirnames, filenames in os.walk(path, followlinks=True):
for f in filenames:
ts_newest = max(ts_newest, get_timestamp(os.path.join(dirpath, f)))
return ts_newest
Reported by Pylint.
Line: 214
Column: 22
subdir = ""
else:
subdir = "/" + script
for dirpath, dirnames, filenames in os.walk(path + subdir, followlinks=True):
for f in filenames:
freeze_internal(kind, path, (dirpath + "/" + f)[len(path) + 1 :], opt)
elif not isinstance(script, str):
# `script` is an iterable of items to freeze
for s in script:
Reported by Pylint.
Line: 285
Column: 17
if input_manifest.endswith(".py"):
include(input_manifest)
else:
exec(input_manifest)
except FreezeError as er:
print('freeze error executing "{}": {}'.format(input_manifest, er.args[0]))
sys.exit(1)
# Process the manifest
Reported by Pylint.
Line: 285
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
if input_manifest.endswith(".py"):
include(input_manifest)
else:
exec(input_manifest)
except FreezeError as er:
print('freeze error executing "{}": {}'.format(input_manifest, er.args[0]))
sys.exit(1)
# Process the manifest
Reported by Bandit.
Line: 1
Column: 1
#!/usr/bin/env python3
#
# This file is part of the MicroPython project, http://micropython.org/
#
# The MIT License (MIT)
#
# Copyright (c) 2019 Damien P. George
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Reported by Pylint.
Line: 30
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
from __future__ import print_function
import sys
import os
import subprocess
###########################################################################
# Public functions to be used in the manifest
Reported by Bandit.
Line: 61
Column: 13
"""
if not isinstance(manifest, str):
for m in manifest:
include(m)
else:
manifest = convert_path(manifest)
with open(manifest) as f:
# Make paths relative to this manifest file while processing it.
Reported by Pylint.
tests/extmod/utimeq1.py
39 issues
Line: 8
Column: 5
from utimeq import utimeq
except ImportError:
print("SKIP")
raise SystemExit
DEBUG = 0
MAX = ticks_add(0, -1)
MODULO_HALF = MAX // 2 + 1
Reported by Pylint.
Line: 23
Column: 1
else:
def dprint(*v):
pass
# Try not to crash on invalid data
h = utimeq(10)
Reported by Pylint.
Line: 43
Column: 5
# unsupported unary op
try:
~h
assert False
except TypeError:
pass
# pushing on full queue
Reported by Pylint.
Line: 78
Column: 13
pass
def pop_all(h):
l = []
while h:
item = [0, 0, 0]
h.pop(item)
# print("!", item)
Reported by Pylint.
Line: 79
Column: 5
def pop_all(h):
l = []
while h:
item = [0, 0, 0]
h.pop(item)
# print("!", item)
l.append(tuple(item))
Reported by Pylint.
Line: 89
Column: 9
return l
def add(h, v):
h.push(v, 0, 0)
dprint("-----")
# h.dump()
dprint("-----")
Reported by Pylint.
Line: 111
Column: 5
def edge_case(edge, offset):
h = utimeq(10)
add(h, ticks_add(0, offset))
add(h, ticks_add(edge, offset))
dprint(h)
l = pop_all(h)
diff = ticks_diff(l[1][0], l[0][0])
Reported by Pylint.
Line: 115
Column: 5
add(h, ticks_add(0, offset))
add(h, ticks_add(edge, offset))
dprint(h)
l = pop_all(h)
diff = ticks_diff(l[1][0], l[0][0])
dprint(diff, diff > 0)
return diff
Reported by Pylint.
Line: 116
Column: 5
add(h, ticks_add(edge, offset))
dprint(h)
l = pop_all(h)
diff = ticks_diff(l[1][0], l[0][0])
dprint(diff, diff > 0)
return diff
dprint("===")
Reported by Pylint.
Line: 1
Column: 1
# Test for utimeq module which implements task queue with support for
# wraparound time (utime.ticks_ms() style).
try:
from utime import ticks_add, ticks_diff
from utimeq import utimeq
except ImportError:
print("SKIP")
raise SystemExit
Reported by Pylint.
drivers/sdcard/sdcard.py
38 issues
Line: 23
Column: 1
"""
from micropython import const
import time
_CMD_TIMEOUT = const(100)
Reported by Pylint.
Line: 127
Column: 13
def init_card_v2(self):
for i in range(_CMD_TIMEOUT):
time.sleep_ms(50)
self.cmd(58, 0, 0, 4)
self.cmd(55, 0, 0)
if self.cmd(41, 0x40000000, 0) == 0:
self.cmd(58, 0, 0, 4)
self.cdv = 1
Reported by Pylint.
Line: 179
Column: 13
self.spi.readinto(self.tokenbuf, 0xFF)
if self.tokenbuf[0] == _TOKEN_DATA:
break
time.sleep_ms(1)
else:
self.cs(1)
raise OSError("timeout waiting for response")
# read data
Reported by Pylint.
Line: 74
Column: 13
self.init_spi(100000)
# clock card at least 100 cycles with cs high
for i in range(16):
self.spi.write(b"\xff")
# CMD0: init card; should return _R1_IDLE_STATE (allow 5 attempts)
for _ in range(5):
if self.cmd(0, 0, 0x95) == _R1_IDLE_STATE:
Reported by Pylint.
Line: 117
Column: 13
self.init_spi(1320000)
def init_card_v1(self):
for i in range(_CMD_TIMEOUT):
self.cmd(55, 0, 0)
if self.cmd(41, 0, 0) == 0:
self.cdv = 512
# print("[SDCard] v1 card")
return
Reported by Pylint.
Line: 120
Column: 17
for i in range(_CMD_TIMEOUT):
self.cmd(55, 0, 0)
if self.cmd(41, 0, 0) == 0:
self.cdv = 512
# print("[SDCard] v1 card")
return
raise OSError("timeout waiting for v1 card")
def init_card_v2(self):
Reported by Pylint.
Line: 126
Column: 13
raise OSError("timeout waiting for v1 card")
def init_card_v2(self):
for i in range(_CMD_TIMEOUT):
time.sleep_ms(50)
self.cmd(58, 0, 0, 4)
self.cmd(55, 0, 0)
if self.cmd(41, 0x40000000, 0) == 0:
self.cmd(58, 0, 0, 4)
Reported by Pylint.
Line: 132
Column: 17
self.cmd(55, 0, 0)
if self.cmd(41, 0x40000000, 0) == 0:
self.cmd(58, 0, 0, 4)
self.cdv = 1
# print("[SDCard] v2 card")
return
raise OSError("timeout waiting for v2 card")
def cmd(self, cmd, arg, crc, final=0, release=True, skip1=False):
Reported by Pylint.
Line: 154
Column: 13
self.spi.readinto(self.tokenbuf, 0xFF)
# wait for the response (response[7] == 0)
for i in range(_CMD_TIMEOUT):
self.spi.readinto(self.tokenbuf, 0xFF)
response = self.tokenbuf[0]
if not (response & 0x80):
# this could be a big-endian integer that we are getting here
for j in range(final):
Reported by Pylint.
Line: 159
Column: 21
response = self.tokenbuf[0]
if not (response & 0x80):
# this could be a big-endian integer that we are getting here
for j in range(final):
self.spi.write(b"\xff")
if release:
self.cs(1)
self.spi.write(b"\xff")
return response
Reported by Pylint.
tests/basics/fun_kwonly.py
38 issues
Line: 10
Column: 1
f(a=1)
# with 2 keyword-only args
def f(*, a, b):
print(a, b)
f(a=1, b=2)
f(b=1, a=2)
Reported by Pylint.
Line: 17
Column: 1
f(b=1, a=2)
# positional followed by bare star
def f(a, *, b, c):
print(a, b, c)
f(1, b=3, c=4)
f(1, c=3, b=4)
f(1, **{'b':'3', 'c':4})
Reported by Pylint.
Line: 25
Column: 5
f(1, **{'b':'3', 'c':4})
try:
f(1)
except TypeError:
print("TypeError")
try:
f(1, b=2)
Reported by Pylint.
Line: 25
Column: 5
f(1, **{'b':'3', 'c':4})
try:
f(1)
except TypeError:
print("TypeError")
try:
f(1, b=2)
Reported by Pylint.
Line: 30
Column: 5
print("TypeError")
try:
f(1, b=2)
except TypeError:
print("TypeError")
try:
f(1, c=2)
Reported by Pylint.
Line: 35
Column: 5
print("TypeError")
try:
f(1, c=2)
except TypeError:
print("TypeError")
# with **kw
def f(a, *, b, **kw):
Reported by Pylint.
Line: 40
Column: 1
print("TypeError")
# with **kw
def f(a, *, b, **kw):
print(a, b, kw)
f(1, b=2)
f(1, b=2, c=3)
Reported by Pylint.
Line: 47
Column: 1
f(1, b=2, c=3)
# with named star
def f(*a, b, c):
print(a, b, c)
f(b=1, c=2)
f(c=1, b=2)
Reported by Pylint.
Line: 54
Column: 1
f(c=1, b=2)
# with positional and named star
def f(a, *b, c):
print(a, b, c)
f(1, c=2)
f(1, 2, c=3)
f(a=1, c=3)
Reported by Pylint.
Line: 62
Column: 1
f(a=1, c=3)
# lambda as kw-only arg (exposes nested behaviour in compiler)
def f(*, x=lambda:1):
return x()
print(f())
print(f(x=f))
print(f(x=lambda:2))
Reported by Pylint.
ports/stm32/make-stmconst.py
38 issues
Line: 43
Column: 5
class LexerError(Exception):
def __init__(self, line):
self.line = line
class Lexer:
re_io_reg = r"__IO uint(?P<bits>8|16|32)_t +(?P<reg>[A-Z0-9]+)"
Reported by Pylint.
Line: 268
Column: 5
reg_defs["GPIO"].append(["BSRRL", 0x18, 16, "legacy register"])
reg_defs["GPIO"].append(["BSRRH", 0x1A, 16, "legacy register"])
modules = []
needed_qstrs = set()
needed_mpzs = set()
print("// Automatically generated from %s by make-stmconst.py" % args.file[0])
print("")
Reported by Pylint.
Line: 1
Column: 1
"""
This script reads in the given CMSIS device include file (eg stm32f405xx.h),
extracts relevant peripheral constants, and creates qstrs, mpz's and constants
for the stm module.
"""
from __future__ import print_function
import argparse
Reported by Pylint.
Line: 17
Column: 5
if platform.python_version_tuple()[0] == "2":
def convert_bytes_to_str(b):
return b
elif platform.python_version_tuple()[0] == "3":
Reported by Pylint.
Line: 17
Column: 5
if platform.python_version_tuple()[0] == "2":
def convert_bytes_to_str(b):
return b
elif platform.python_version_tuple()[0] == "3":
Reported by Pylint.
Line: 23
Column: 5
elif platform.python_version_tuple()[0] == "3":
def convert_bytes_to_str(b):
try:
return str(b, "utf8")
except ValueError:
# some files have invalid utf8 bytes, so filter them out
return "".join(chr(l) for l in b if l <= 126)
Reported by Pylint.
Line: 23
Column: 5
elif platform.python_version_tuple()[0] == "3":
def convert_bytes_to_str(b):
try:
return str(b, "utf8")
except ValueError:
# some files have invalid utf8 bytes, so filter them out
return "".join(chr(l) for l in b if l <= 126)
Reported by Pylint.
Line: 34
Column: 1
# end compatibility code
# given a list of (name,regex) pairs, find the first one that matches the given line
def re_match_first(regexs, line):
for name, regex in regexs:
match = re.match(regex, line)
if match:
return name, match
return None, None
Reported by Pylint.
Line: 42
Column: 1
return None, None
class LexerError(Exception):
def __init__(self, line):
self.line = line
class Lexer:
Reported by Pylint.
Line: 47
Column: 1
self.line = line
class Lexer:
re_io_reg = r"__IO uint(?P<bits>8|16|32)_t +(?P<reg>[A-Z0-9]+)"
re_comment = r"(?P<comment>[A-Za-z0-9 \-/_()&:\[\]]+)"
re_addr_offset = r"Address offset: (?P<offset>0x[0-9A-Z]{2,3})"
regexs = (
(
Reported by Pylint.