The following issues were found
tests/basics/fun_kwvarargs.py
11 issues
Line: 1
Column: 1
def f1(**kwargs):
print(kwargs)
f1()
f1(a=1)
def f2(a, **kwargs):
print(a, kwargs)
Reported by Pylint.
Line: 1
Column: 1
def f1(**kwargs):
print(kwargs)
f1()
f1(a=1)
def f2(a, **kwargs):
print(a, kwargs)
Reported by Pylint.
Line: 1
Column: 1
def f1(**kwargs):
print(kwargs)
f1()
f1(a=1)
def f2(a, **kwargs):
print(a, kwargs)
Reported by Pylint.
Line: 7
Column: 1
f1()
f1(a=1)
def f2(a, **kwargs):
print(a, kwargs)
f2(1)
f2(1, b=2)
Reported by Pylint.
Line: 7
Column: 1
f1()
f1(a=1)
def f2(a, **kwargs):
print(a, kwargs)
f2(1)
f2(1, b=2)
Reported by Pylint.
Line: 7
Column: 1
f1()
f1(a=1)
def f2(a, **kwargs):
print(a, kwargs)
f2(1)
f2(1, b=2)
Reported by Pylint.
Line: 13
Column: 1
f2(1)
f2(1, b=2)
def f3(a, *vargs, **kwargs):
print(a, vargs, kwargs)
f3(1)
f3(1, 2)
f3(1, b=2)
Reported by Pylint.
Line: 13
Column: 1
f2(1)
f2(1, b=2)
def f3(a, *vargs, **kwargs):
print(a, vargs, kwargs)
f3(1)
f3(1, 2)
f3(1, b=2)
Reported by Pylint.
Line: 13
Column: 1
f2(1)
f2(1, b=2)
def f3(a, *vargs, **kwargs):
print(a, vargs, kwargs)
f3(1)
f3(1, 2)
f3(1, b=2)
Reported by Pylint.
Line: 21
Column: 1
f3(1, b=2)
f3(1, 2, b=3)
def f4(*vargs, **kwargs):
print(vargs, kwargs)
f4(*(1, 2))
f4(kw_arg=3)
f4(*(1, 2), kw_arg=3)
Reported by Pylint.
tests/extmod/uasyncio_cancel_fair.py
11 issues
Line: 11
Column: 9
import asyncio
except ImportError:
print("SKIP")
raise SystemExit
async def task(id, other):
for i in range(3):
try:
Reported by Pylint.
Line: 14
Column: 16
raise SystemExit
async def task(id, other):
for i in range(3):
try:
print("start", id)
await asyncio.sleep(0)
print("done", id)
Reported by Pylint.
Line: 15
Column: 9
async def task(id, other):
for i in range(3):
try:
print("start", id)
await asyncio.sleep(0)
print("done", id)
except asyncio.CancelledError as er:
Reported by Pylint.
Line: 20
Column: 9
print("start", id)
await asyncio.sleep(0)
print("done", id)
except asyncio.CancelledError as er:
print("cancelled", id)
if other is not None:
print(id, "cancels", other)
tasks[other].cancel()
Reported by Pylint.
Line: 28
Column: 5
async def main():
global tasks
tasks = [
asyncio.create_task(task(0, 1)),
asyncio.create_task(task(1, 0)),
asyncio.create_task(task(2, None)),
]
Reported by Pylint.
Line: 1
Column: 1
# Test fairness of cancelling a task
# That tasks which continuously cancel each other don't take over the scheduler
try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio
except ImportError:
Reported by Pylint.
Line: 14
Column: 1
raise SystemExit
async def task(id, other):
for i in range(3):
try:
print("start", id)
await asyncio.sleep(0)
print("done", id)
Reported by Pylint.
Line: 14
Column: 1
raise SystemExit
async def task(id, other):
for i in range(3):
try:
print("start", id)
await asyncio.sleep(0)
print("done", id)
Reported by Pylint.
Line: 20
Column: 9
print("start", id)
await asyncio.sleep(0)
print("done", id)
except asyncio.CancelledError as er:
print("cancelled", id)
if other is not None:
print(id, "cancels", other)
tasks[other].cancel()
Reported by Pylint.
Line: 27
Column: 1
tasks[other].cancel()
async def main():
global tasks
tasks = [
asyncio.create_task(task(0, 1)),
asyncio.create_task(task(1, 0)),
asyncio.create_task(task(2, None)),
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/basics/gen_yield_from_throw3.py
11 issues
Line: 48
Column: 1
print(next(g))
try:
g.throw(ValueError)
except:
print('ValueError')
# the thrown 123 is not an exception so raises a TypeError
g = gen2()
print(next(g))
Reported by Pylint.
Line: 1
Column: 1
# yield-from a user-defined generator with a throw() method
class Iter:
def __iter__(self):
return self
def __next__(self):
return 1
Reported by Pylint.
Line: 3
Column: 1
# yield-from a user-defined generator with a throw() method
class Iter:
def __iter__(self):
return self
def __next__(self):
return 1
Reported by Pylint.
Line: 7
Column: 5
def __iter__(self):
return self
def __next__(self):
return 1
def throw(self, x):
print('throw', x)
return 456
Reported by Pylint.
Line: 10
Column: 5
def __next__(self):
return 1
def throw(self, x):
print('throw', x)
return 456
def gen():
yield from Iter()
Reported by Pylint.
Line: 10
Column: 5
def __next__(self):
return 1
def throw(self, x):
print('throw', x)
return 456
def gen():
yield from Iter()
Reported by Pylint.
Line: 10
Column: 5
def __next__(self):
return 1
def throw(self, x):
print('throw', x)
return 456
def gen():
yield from Iter()
Reported by Pylint.
Line: 14
Column: 1
print('throw', x)
return 456
def gen():
yield from Iter()
# calling close() should not call throw()
g = gen()
print(next(g))
Reported by Pylint.
Line: 33
Column: 1
print(g.throw(ZeroDivisionError))
# this user-defined generator doesn't have a throw() method
class Iter2:
def __iter__(self):
return self
def __next__(self):
return 1
Reported by Pylint.
Line: 37
Column: 5
def __iter__(self):
return self
def __next__(self):
return 1
def gen2():
yield from Iter2()
Reported by Pylint.
tests/basics/fun_defargs.py
11 issues
Line: 16
Column: 5
fun2(1, None)
fun2(0, "bar", 200)
try:
fun2()
except TypeError:
print("TypeError")
try:
fun2(1, 2, 3, 4)
except TypeError:
Reported by Pylint.
Line: 20
Column: 5
except TypeError:
print("TypeError")
try:
fun2(1, 2, 3, 4)
except TypeError:
print("TypeError")
# lambda as default arg (exposes nested behaviour in compiler)
def f(x=lambda:1):
Reported by Pylint.
Line: 1
Column: 1
# testing default args to a function
def fun1(val=5):
print(val)
fun1()
fun1(10)
def fun2(p1, p2=100, p3="foo"):
Reported by Pylint.
Line: 3
Column: 1
# testing default args to a function
def fun1(val=5):
print(val)
fun1()
fun1(10)
def fun2(p1, p2=100, p3="foo"):
Reported by Pylint.
Line: 9
Column: 1
fun1()
fun1(10)
def fun2(p1, p2=100, p3="foo"):
print(p1, p2, p3)
fun2(1)
fun2(1, None)
fun2(0, "bar", 200)
Reported by Pylint.
Line: 9
Column: 1
fun1()
fun1(10)
def fun2(p1, p2=100, p3="foo"):
print(p1, p2, p3)
fun2(1)
fun2(1, None)
fun2(0, "bar", 200)
Reported by Pylint.
Line: 9
Column: 1
fun1()
fun1(10)
def fun2(p1, p2=100, p3="foo"):
print(p1, p2, p3)
fun2(1)
fun2(1, None)
fun2(0, "bar", 200)
Reported by Pylint.
Line: 9
Column: 1
fun1()
fun1(10)
def fun2(p1, p2=100, p3="foo"):
print(p1, p2, p3)
fun2(1)
fun2(1, None)
fun2(0, "bar", 200)
Reported by Pylint.
Line: 25
Column: 1
print("TypeError")
# lambda as default arg (exposes nested behaviour in compiler)
def f(x=lambda:1):
return x()
print(f())
print(f(f))
print(f(lambda:2))
Reported by Pylint.
Line: 25
Column: 1
print("TypeError")
# lambda as default arg (exposes nested behaviour in compiler)
def f(x=lambda:1):
return x()
print(f())
print(f(f))
print(f(lambda:2))
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/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/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.
tests/perf_bench/viper_call2a.py
11 issues
Line: 1
Column: 2
@micropython.viper
def f2a(x, y):
return x
@micropython.native
def call(r):
f = f2a
for _ in r:
Reported by Pylint.
Line: 6
Column: 2
return x
@micropython.native
def call(r):
f = f2a
for _ in r:
f(1, 2)
Reported by Pylint.
Line: 2
Column: 12
@micropython.viper
def f2a(x, y):
return x
@micropython.native
def call(r):
f = f2a
for _ in r:
Reported by Pylint.
Line: 1
Column: 1
@micropython.viper
def f2a(x, y):
return x
@micropython.native
def call(r):
f = f2a
for _ in r:
Reported by Pylint.
Line: 2
Column: 1
@micropython.viper
def f2a(x, y):
return x
@micropython.native
def call(r):
f = f2a
for _ in r:
Reported by Pylint.
Line: 2
Column: 1
@micropython.viper
def f2a(x, y):
return x
@micropython.native
def call(r):
f = f2a
for _ in r:
Reported by Pylint.
Line: 2
Column: 1
@micropython.viper
def f2a(x, y):
return x
@micropython.native
def call(r):
f = f2a
for _ in r:
Reported by Pylint.
Line: 7
Column: 1
@micropython.native
def call(r):
f = f2a
for _ in r:
f(1, 2)
Reported by Pylint.
Line: 7
Column: 1
@micropython.native
def call(r):
f = f2a
for _ in r:
f(1, 2)
Reported by Pylint.
Line: 8
Column: 5
@micropython.native
def call(r):
f = f2a
for _ in r:
f(1, 2)
bm_params = {
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.