The following issues were found
tests/extmod/btree_error.py
11 issues
Line: 6
Column: 5
try:
import btree, uio, uerrno
uio.IOBase
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 9
Column: 5
uio.IOBase
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
class Device(uio.IOBase):
def __init__(self, read_ret=0, ioctl_ret=0):
self.read_ret = read_ret
Reported by Pylint.
Line: 21
Column: 26
print("read", len(buf))
return self.read_ret
def ioctl(self, cmd, arg):
print("ioctl", cmd)
return self.ioctl_ret
# Invalid pagesize; errno comes from btree library
Reported by Pylint.
Line: 1
Column: 1
# Test that errno's propagate correctly through btree module.
try:
import btree, uio, uerrno
uio.IOBase
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 4
Column: 5
# Test that errno's propagate correctly through btree module.
try:
import btree, uio, uerrno
uio.IOBase
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 12
Column: 1
raise SystemExit
class Device(uio.IOBase):
def __init__(self, read_ret=0, ioctl_ret=0):
self.read_ret = read_ret
self.ioctl_ret = ioctl_ret
def readinto(self, buf):
Reported by Pylint.
Line: 17
Column: 5
self.read_ret = read_ret
self.ioctl_ret = ioctl_ret
def readinto(self, buf):
print("read", len(buf))
return self.read_ret
def ioctl(self, cmd, arg):
print("ioctl", cmd)
Reported by Pylint.
Line: 21
Column: 5
print("read", len(buf))
return self.read_ret
def ioctl(self, cmd, arg):
print("ioctl", cmd)
return self.ioctl_ret
# Invalid pagesize; errno comes from btree library
Reported by Pylint.
Line: 29
Column: 1
# Invalid pagesize; errno comes from btree library
try:
db = btree.open(Device(), pagesize=511)
except OSError as er:
print("OSError", er.errno == uerrno.EINVAL)
# Valid pagesize, device returns error on read; errno comes from Device.readinto
try:
db = btree.open(Device(-1000), pagesize=512)
Reported by Pylint.
Line: 35
Column: 1
# Valid pagesize, device returns error on read; errno comes from Device.readinto
try:
db = btree.open(Device(-1000), pagesize=512)
except OSError as er:
print(repr(er))
# Valid pagesize, device returns error on seek; errno comes from Device.ioctl
try:
db = btree.open(Device(0, -1001), pagesize=512)
Reported by Pylint.
tests/basics/async_with.py
11 issues
Line: 38
Column: 8
o = h()
try:
o.send(None)
except BaseException:
print('BaseException')
Reported by Pylint.
Line: 1
Column: 1
# test simple async with execution
class AContext:
async def __aenter__(self):
print('enter')
return 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
Reported by Pylint.
Line: 3
Column: 1
# test simple async with execution
class AContext:
async def __aenter__(self):
print('enter')
return 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
Reported by Pylint.
Line: 7
Column: 5
async def __aenter__(self):
print('enter')
return 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
async def f():
async with AContext():
print('body')
Reported by Pylint.
Line: 10
Column: 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
async def f():
async with AContext():
print('body')
o = f()
try:
Reported by Pylint.
Line: 10
Column: 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
async def f():
async with AContext():
print('body')
o = f()
try:
Reported by Pylint.
Line: 20
Column: 1
except StopIteration:
print('finished')
async def g():
async with AContext() as ac:
print(ac)
raise ValueError('error')
o = g()
Reported by Pylint.
Line: 20
Column: 1
except StopIteration:
print('finished')
async def g():
async with AContext() as ac:
print(ac)
raise ValueError('error')
o = g()
Reported by Pylint.
Line: 21
Column: 30
print('finished')
async def g():
async with AContext() as ac:
print(ac)
raise ValueError('error')
o = g()
try:
Reported by Pylint.
Line: 32
Column: 1
print('ValueError')
# test raising BaseException to make sure it is handled by the async-with
async def h():
async with AContext():
raise BaseException
o = h()
try:
o.send(None)
Reported by Pylint.
tests/esp32/partition_ota.py
11 issues
Line: 5
Column: 1
# Running this test requires firmware with an OTA Partition, such as the GENERIC_OTA "board".
# This test also requires patience as it copies the boot partition into the other OTA slot.
import machine
from esp32 import Partition
# start by checking that the running partition table has OTA partitions, 'cause if
# it doesn't there's nothing we can test
cur = Partition(Partition.RUNNING)
Reported by Pylint.
Line: 6
Column: 1
# This test also requires patience as it copies the boot partition into the other OTA slot.
import machine
from esp32 import Partition
# start by checking that the running partition table has OTA partitions, 'cause if
# it doesn't there's nothing we can test
cur = Partition(Partition.RUNNING)
cur_name = cur.info()[4]
Reported by Pylint.
Line: 25
Column: 1
# replace boot.py with the test code that will run on each reboot
import uos
try:
uos.rename("boot.py", "boot-orig.py")
except:
pass
Reported by Pylint.
Line: 29
Column: 1
try:
uos.rename("boot.py", "boot-orig.py")
except:
pass
with open("boot.py", "w") as f:
f.write("DEBUG=" + str(DEBUG))
f.write(
"""
Reported by Pylint.
Line: 1
Column: 1
# Test ESP32 OTA updates, including automatic roll-back.
# Running this test requires firmware with an OTA Partition, such as the GENERIC_OTA "board".
# This test also requires patience as it copies the boot partition into the other OTA slot.
import machine
from esp32 import Partition
# start by checking that the running partition table has OTA partitions, 'cause if
# it doesn't there's nothing we can test
Reported by Pylint.
Line: 19
Column: 1
DEBUG = True
def log(*args):
if DEBUG:
print(*args)
# replace boot.py with the test code that will run on each reboot
Reported by Pylint.
Line: 25
Column: 1
# replace boot.py with the test code that will run on each reboot
import uos
try:
uos.rename("boot.py", "boot-orig.py")
except:
pass
Reported by Pylint.
Line: 25
Column: 1
# replace boot.py with the test code that will run on each reboot
import uos
try:
uos.rename("boot.py", "boot-orig.py")
except:
pass
Reported by Pylint.
Line: 29
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html
try:
uos.rename("boot.py", "boot-orig.py")
except:
pass
with open("boot.py", "w") as f:
f.write("DEBUG=" + str(DEBUG))
f.write(
"""
Reported by Bandit.
Line: 87
Column: 1
)
def copy_partition(src, dest):
log("Partition copy: {} --> {}".format(src.info(), dest.info()))
sz = src.info()[3]
if dest.info()[3] != sz:
raise ValueError("Sizes don't match: {} vs {}".format(sz, dest.info()[3]))
addr = 0
Reported by Pylint.
tests/extmod/framebuf_subclass.py
11 issues
Line: 7
Column: 5
import framebuf, usys
except ImportError:
print("SKIP")
raise SystemExit
# This test and its .exp file is based on a little-endian architecture.
if usys.byteorder != "little":
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 1
Column: 1
# test subclassing framebuf.FrameBuffer
try:
import framebuf, usys
except ImportError:
print("SKIP")
raise SystemExit
# This test and its .exp file is based on a little-endian architecture.
Reported by Pylint.
Line: 4
Column: 5
# test subclassing framebuf.FrameBuffer
try:
import framebuf, usys
except ImportError:
print("SKIP")
raise SystemExit
# This test and its .exp file is based on a little-endian architecture.
Reported by Pylint.
Line: 15
Column: 1
raise SystemExit
class FB(framebuf.FrameBuffer):
def __init__(self, n):
self.n = n
super().__init__(bytearray(2 * n * n), n, n, framebuf.RGB565)
def foo(self):
Reported by Pylint.
Line: 15
Column: 1
raise SystemExit
class FB(framebuf.FrameBuffer):
def __init__(self, n):
self.n = n
super().__init__(bytearray(2 * n * n), n, n, framebuf.RGB565)
def foo(self):
Reported by Pylint.
Line: 16
Column: 5
class FB(framebuf.FrameBuffer):
def __init__(self, n):
self.n = n
super().__init__(bytearray(2 * n * n), n, n, framebuf.RGB565)
def foo(self):
self.hline(0, 2, self.n, 0x0304)
Reported by Pylint.
Line: 17
Column: 9
class FB(framebuf.FrameBuffer):
def __init__(self, n):
self.n = n
super().__init__(bytearray(2 * n * n), n, n, framebuf.RGB565)
def foo(self):
self.hline(0, 2, self.n, 0x0304)
Reported by Pylint.
Line: 20
Column: 5
self.n = n
super().__init__(bytearray(2 * n * n), n, n, framebuf.RGB565)
def foo(self):
self.hline(0, 2, self.n, 0x0304)
fb = FB(n=3)
fb.pixel(0, 0, 0x0102)
Reported by Pylint.
Line: 20
Column: 5
self.n = n
super().__init__(bytearray(2 * n * n), n, n, framebuf.RGB565)
def foo(self):
self.hline(0, 2, self.n, 0x0304)
fb = FB(n=3)
fb.pixel(0, 0, 0x0102)
Reported by Pylint.
Line: 38
Column: 1
print(bytes(fb2))
# Test that blitting something that isn't a subclass fails with TypeError.
class NotAFrameBuf:
pass
try:
fb.blit(NotAFrameBuf(), 0, 0)
Reported by Pylint.
tests/basics/try_else.py
11 issues
Line: 6
Column: 1
# base case
try:
print(1)
except:
print(2)
else:
print(3)
# basic case that should skip else
Reported by Pylint.
Line: 15
Column: 1
try:
print(1)
raise Exception
except:
print(2)
else:
print(3)
# uncaught exception should skip else
Reported by Pylint.
Line: 29
Column: 1
print(2)
else:
print(3)
except:
print('caught')
# nested within outer try
try:
print(1)
Reported by Pylint.
Line: 38
Column: 5
try:
print(2)
raise Exception
except:
print(3)
else:
print(4)
except:
print(5)
Reported by Pylint.
Line: 42
Column: 1
print(3)
else:
print(4)
except:
print(5)
else:
print(6)
# nested within outer except, one else should be skipped
Reported by Pylint.
Line: 51
Column: 1
try:
print(1)
raise Exception
except:
print(2)
try:
print(3)
except:
print(4)
Reported by Pylint.
Line: 55
Column: 5
print(2)
try:
print(3)
except:
print(4)
else:
print(5)
else:
print(6)
Reported by Pylint.
Line: 66
Column: 1
try:
print(1)
raise Exception
except:
print(2)
try:
print(3)
raise Exception
except:
Reported by Pylint.
Line: 70
Column: 9
print(2)
try:
print(3)
raise Exception
except:
print(4)
else:
print(5)
else:
Reported by Pylint.
Line: 71
Column: 5
try:
print(3)
raise Exception
except:
print(4)
else:
print(5)
else:
print(6)
Reported by Pylint.
ports/esp8266/boards/GENERIC/manifest.py
11 issues
Line: 2
Column: 1
# base modules
include("$(PORT_DIR)/boards/manifest.py")
# uasyncio
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
# drivers
freeze("$(MPY_DIR)/drivers/display", "ssd1306.py")
Reported by Pylint.
Line: 5
Column: 1
include("$(PORT_DIR)/boards/manifest.py")
# uasyncio
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
# drivers
freeze("$(MPY_DIR)/drivers/display", "ssd1306.py")
# Libraries from micropython-lib, include only if the library directory exists
Reported by Pylint.
Line: 8
Column: 1
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
# drivers
freeze("$(MPY_DIR)/drivers/display", "ssd1306.py")
# Libraries from micropython-lib, include only if the library directory exists
if os.path.isdir(convert_path("$(MPY_LIB_DIR)")):
# file utilities
freeze("$(MPY_LIB_DIR)/micropython/upysh", "upysh.py")
Reported by Pylint.
Line: 11
Column: 4
freeze("$(MPY_DIR)/drivers/display", "ssd1306.py")
# Libraries from micropython-lib, include only if the library directory exists
if os.path.isdir(convert_path("$(MPY_LIB_DIR)")):
# file utilities
freeze("$(MPY_LIB_DIR)/micropython/upysh", "upysh.py")
# requests
freeze("$(MPY_LIB_DIR)/python-ecosys/urequests", "urequests.py")
Reported by Pylint.
Line: 11
Column: 18
freeze("$(MPY_DIR)/drivers/display", "ssd1306.py")
# Libraries from micropython-lib, include only if the library directory exists
if os.path.isdir(convert_path("$(MPY_LIB_DIR)")):
# file utilities
freeze("$(MPY_LIB_DIR)/micropython/upysh", "upysh.py")
# requests
freeze("$(MPY_LIB_DIR)/python-ecosys/urequests", "urequests.py")
Reported by Pylint.
Line: 13
Column: 5
# Libraries from micropython-lib, include only if the library directory exists
if os.path.isdir(convert_path("$(MPY_LIB_DIR)")):
# file utilities
freeze("$(MPY_LIB_DIR)/micropython/upysh", "upysh.py")
# requests
freeze("$(MPY_LIB_DIR)/python-ecosys/urequests", "urequests.py")
freeze("$(MPY_LIB_DIR)/micropython/urllib.urequest", "urllib/urequest.py")
Reported by Pylint.
Line: 16
Column: 5
freeze("$(MPY_LIB_DIR)/micropython/upysh", "upysh.py")
# requests
freeze("$(MPY_LIB_DIR)/python-ecosys/urequests", "urequests.py")
freeze("$(MPY_LIB_DIR)/micropython/urllib.urequest", "urllib/urequest.py")
# umqtt
freeze("$(MPY_LIB_DIR)/micropython/umqtt.simple", "umqtt/simple.py")
freeze("$(MPY_LIB_DIR)/micropython/umqtt.robust", "umqtt/robust.py")
Reported by Pylint.
Line: 17
Column: 5
# requests
freeze("$(MPY_LIB_DIR)/python-ecosys/urequests", "urequests.py")
freeze("$(MPY_LIB_DIR)/micropython/urllib.urequest", "urllib/urequest.py")
# umqtt
freeze("$(MPY_LIB_DIR)/micropython/umqtt.simple", "umqtt/simple.py")
freeze("$(MPY_LIB_DIR)/micropython/umqtt.robust", "umqtt/robust.py")
Reported by Pylint.
Line: 20
Column: 5
freeze("$(MPY_LIB_DIR)/micropython/urllib.urequest", "urllib/urequest.py")
# umqtt
freeze("$(MPY_LIB_DIR)/micropython/umqtt.simple", "umqtt/simple.py")
freeze("$(MPY_LIB_DIR)/micropython/umqtt.robust", "umqtt/robust.py")
Reported by Pylint.
Line: 21
Column: 5
# umqtt
freeze("$(MPY_LIB_DIR)/micropython/umqtt.simple", "umqtt/simple.py")
freeze("$(MPY_LIB_DIR)/micropython/umqtt.robust", "umqtt/robust.py")
Reported by Pylint.
tests/extmod/ure_sub.py
11 issues
Line: 8
Column: 9
import re
except ImportError:
print("SKIP")
raise SystemExit
try:
re.sub
except AttributeError:
print("SKIP")
Reported by Pylint.
Line: 14
Column: 5
re.sub
except AttributeError:
print("SKIP")
raise SystemExit
def multiply(m):
return str(int(m.group(0)) * 2)
Reported by Pylint.
Line: 21
Column: 15
return str(int(m.group(0)) * 2)
print(re.sub("\d+", multiply, "10 20 30 40 50"))
print(re.sub("\d+", lambda m: str(int(m.group(0)) // 2), "10 20 30 40 50"))
def A():
Reported by Pylint.
Line: 23
Column: 15
print(re.sub("\d+", multiply, "10 20 30 40 50"))
print(re.sub("\d+", lambda m: str(int(m.group(0)) // 2), "10 20 30 40 50"))
def A():
return "A"
Reported by Pylint.
Line: 58
Column: 1
# invalid group
try:
re.sub("(a)", "b\\2", "a")
except:
print("invalid group")
# invalid group with very large number (to test overflow in uPy)
try:
re.sub("(a)", "b\\199999999999999999999999999999999999999", "a")
Reported by Pylint.
Line: 64
Column: 1
# invalid group with very large number (to test overflow in uPy)
try:
re.sub("(a)", "b\\199999999999999999999999999999999999999", "a")
except:
print("invalid group")
# Module function takes str/bytes/re.
print(re.sub("a", "a", "a"))
print(re.sub(b".", b"a", b"a"))
Reported by Pylint.
Line: 1
Column: 1
try:
import ure as re
except ImportError:
try:
import re
except ImportError:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 17
Column: 1
raise SystemExit
def multiply(m):
return str(int(m.group(0)) * 2)
print(re.sub("\d+", multiply, "10 20 30 40 50"))
Reported by Pylint.
Line: 17
Column: 1
raise SystemExit
def multiply(m):
return str(int(m.group(0)) * 2)
print(re.sub("\d+", multiply, "10 20 30 40 50"))
Reported by Pylint.
Line: 26
Column: 1
print(re.sub("\d+", lambda m: str(int(m.group(0)) // 2), "10 20 30 40 50"))
def A():
return "A"
print(re.sub("a", A(), "aBCBABCDabcda."))
Reported by Pylint.
tests/basics/try_else_finally.py
11 issues
Line: 6
Column: 1
# base case
try:
print(1)
except:
print(2)
else:
print(3)
finally:
print(4)
Reported by Pylint.
Line: 17
Column: 1
try:
print(1)
raise Exception
except:
print(2)
else:
print(3)
finally:
print(4)
Reported by Pylint.
Line: 35
Column: 1
print(3)
finally:
print(4)
except:
print('caught')
# nested within outer try
try:
print(1)
Reported by Pylint.
Line: 44
Column: 5
try:
print(2)
raise Exception
except:
print(3)
else:
print(4)
finally:
print(5)
Reported by Pylint.
Line: 50
Column: 1
print(4)
finally:
print(5)
except:
print(6)
else:
print(7)
finally:
print(8)
Reported by Pylint.
Line: 61
Column: 1
try:
print(1)
raise Exception
except:
print(2)
try:
print(3)
except:
print(4)
Reported by Pylint.
Line: 65
Column: 5
print(2)
try:
print(3)
except:
print(4)
else:
print(5)
finally:
print(6)
Reported by Pylint.
Line: 80
Column: 1
try:
print(1)
raise Exception
except:
print(2)
try:
print(3)
raise Exception
except:
Reported by Pylint.
Line: 84
Column: 9
print(2)
try:
print(3)
raise Exception
except:
print(4)
else:
print(5)
finally:
Reported by Pylint.
Line: 85
Column: 5
try:
print(3)
raise Exception
except:
print(4)
else:
print(5)
finally:
print(6)
Reported by Pylint.
tests/pyb/timer_callback.py
11 issues
Line: 3
Column: 1
# check callback feature of the timer class
import pyb
from pyb import Timer
# callback function that disables the callback when called
def cb1(t):
print("cb1")
t.callback(None)
Reported by Pylint.
Line: 4
Column: 1
# check callback feature of the timer class
import pyb
from pyb import Timer
# callback function that disables the callback when called
def cb1(t):
print("cb1")
t.callback(None)
Reported by Pylint.
Line: 1
Column: 1
# check callback feature of the timer class
import pyb
from pyb import Timer
# callback function that disables the callback when called
def cb1(t):
print("cb1")
t.callback(None)
Reported by Pylint.
Line: 7
Column: 1
from pyb import Timer
# callback function that disables the callback when called
def cb1(t):
print("cb1")
t.callback(None)
# callback function that disables the timer when called
Reported by Pylint.
Line: 7
Column: 1
from pyb import Timer
# callback function that disables the callback when called
def cb1(t):
print("cb1")
t.callback(None)
# callback function that disables the timer when called
Reported by Pylint.
Line: 13
Column: 1
# callback function that disables the timer when called
def cb2(t):
print("cb2")
t.deinit()
# callback where cb4 closes over cb3.y
Reported by Pylint.
Line: 13
Column: 1
# callback function that disables the timer when called
def cb2(t):
print("cb2")
t.deinit()
# callback where cb4 closes over cb3.y
Reported by Pylint.
Line: 19
Column: 1
# callback where cb4 closes over cb3.y
def cb3(x):
y = x
def cb4(t):
print("cb4", y)
t.callback(None)
Reported by Pylint.
Line: 19
Column: 1
# callback where cb4 closes over cb3.y
def cb3(x):
y = x
def cb4(t):
print("cb4", y)
t.callback(None)
Reported by Pylint.
Line: 20
Column: 5
# callback where cb4 closes over cb3.y
def cb3(x):
y = x
def cb4(t):
print("cb4", y)
t.callback(None)
Reported by Pylint.
tests/basics/try4.py
11 issues
Line: 5
Column: 9
def f():
try:
foo()
except:
print("except 1")
try:
bar()
except:
Reported by Pylint.
Line: 9
Column: 13
except:
print("except 1")
try:
bar()
except:
print("except 2")
try:
baz()
except:
Reported by Pylint.
Line: 13
Column: 17
except:
print("except 2")
try:
baz()
except:
print("except 3")
bak()
try:
Reported by Pylint.
Line: 16
Column: 13
baz()
except:
print("except 3")
bak()
try:
f()
except:
print("f except")
Reported by Pylint.
Line: 6
Column: 5
def f():
try:
foo()
except:
print("except 1")
try:
bar()
except:
print("except 2")
Reported by Pylint.
Line: 10
Column: 9
print("except 1")
try:
bar()
except:
print("except 2")
try:
baz()
except:
print("except 3")
Reported by Pylint.
Line: 14
Column: 13
print("except 2")
try:
baz()
except:
print("except 3")
bak()
try:
f()
Reported by Pylint.
Line: 20
Column: 1
try:
f()
except:
print("f except")
Reported by Pylint.
Line: 1
Column: 1
# triple nested exceptions
def f():
try:
foo()
except:
print("except 1")
try:
bar()
Reported by Pylint.
Line: 3
Column: 1
# triple nested exceptions
def f():
try:
foo()
except:
print("except 1")
try:
bar()
Reported by Pylint.