The following issues were found
tests/micropython/viper_ptr8_load.py
17 issues
Line: 4
Column: 2
# test loading from ptr8 type
@micropython.viper
def get(src: ptr8) -> int:
return src[0]
@micropython.viper
Reported by Pylint.
Line: 5
Column: 14
@micropython.viper
def get(src: ptr8) -> int:
return src[0]
@micropython.viper
def get1(src: ptr8) -> int:
Reported by Pylint.
Line: 9
Column: 2
return src[0]
@micropython.viper
def get1(src: ptr8) -> int:
return src[1]
@micropython.viper
Reported by Pylint.
Line: 10
Column: 15
@micropython.viper
def get1(src: ptr8) -> int:
return src[1]
@micropython.viper
def memadd(src: ptr8, n: int) -> int:
Reported by Pylint.
Line: 14
Column: 2
return src[1]
@micropython.viper
def memadd(src: ptr8, n: int) -> int:
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 15
Column: 17
@micropython.viper
def memadd(src: ptr8, n: int) -> int:
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 22
Column: 2
return sum
@micropython.viper
def memadd2(src_in) -> int:
src = ptr8(src_in)
n = int(len(src_in))
sum = 0
for i in range(n):
Reported by Pylint.
Line: 24
Column: 11
@micropython.viper
def memadd2(src_in) -> int:
src = ptr8(src_in)
n = int(len(src_in))
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 16
Column: 5
@micropython.viper
def memadd(src: ptr8, n: int) -> int:
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 26
Column: 5
def memadd2(src_in) -> int:
src = ptr8(src_in)
n = int(len(src_in))
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
tests/float/complex1.py
17 issues
Line: 89
Column: 5
# unsupported unary op
try:
~(1j)
except TypeError:
print("TypeError")
# unsupported binary op
try:
Reported by Pylint.
Line: 1
Column: 1
# test basic complex number functionality
# constructor
print(complex(1))
print(complex(1.2))
print(complex(1.2j))
print(complex("1"))
print(complex("1.2"))
print(complex("1.2j"))
Reported by Pylint.
Line: 30
Column: 1
print(1j / 2)
print((1j / 2j).real)
print(1j / (1 + 2j))
ans = 0j ** 0
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 0j ** 1
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 0j ** 0j
print("%.5g %.5g" % (ans.real, ans.imag))
Reported by Pylint.
Line: 32
Column: 1
print(1j / (1 + 2j))
ans = 0j ** 0
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 0j ** 1
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 0j ** 0j
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 1j ** 2.5
print("%.5g %.5g" % (ans.real, ans.imag))
Reported by Pylint.
Line: 34
Column: 1
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 0j ** 1
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 0j ** 0j
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 1j ** 2.5
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 1j ** 2.5j
print("%.5g %.5g" % (ans.real, ans.imag))
Reported by Pylint.
Line: 36
Column: 1
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 0j ** 0j
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 1j ** 2.5
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 1j ** 2.5j
print("%.5g %.5g" % (ans.real, ans.imag))
# comparison
Reported by Pylint.
Line: 38
Column: 1
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 1j ** 2.5
print("%.5g %.5g" % (ans.real, ans.imag))
ans = 1j ** 2.5j
print("%.5g %.5g" % (ans.real, ans.imag))
# comparison
print(1j == 1)
print(1j == 1j)
Reported by Pylint.
Line: 43
Column: 7
# comparison
print(1j == 1)
print(1j == 1j)
print(0 + 0j == False, 1 + 0j == True)
print(False == 0 + 0j, True == 1 + 0j)
# comparison of nan is special
nan = float("nan") * 1j
Reported by Pylint.
Line: 44
Column: 7
# comparison
print(1j == 1)
print(1j == 1j)
print(0 + 0j == False, 1 + 0j == True)
print(False == 0 + 0j, True == 1 + 0j)
# comparison of nan is special
nan = float("nan") * 1j
print(nan == 1j)
Reported by Pylint.
Line: 44
Column: 24
# comparison
print(1j == 1)
print(1j == 1j)
print(0 + 0j == False, 1 + 0j == True)
print(False == 0 + 0j, True == 1 + 0j)
# comparison of nan is special
nan = float("nan") * 1j
print(nan == 1j)
Reported by Pylint.
ports/stm32/boards/STM32F4DISC/staccel.py
17 issues
Line: 17
Column: 1
STM32Cube_FW_F4_V1.1.0/Projects/STM32F4-Discovery/Demonstrations/Src/main.c
"""
from micropython import const
from pyb import Pin
from pyb import SPI
READWRITE_CMD = const(0x80)
MULTIPLEBYTE_CMD = const(0x40)
Reported by Pylint.
Line: 18
Column: 1
"""
from micropython import const
from pyb import Pin
from pyb import SPI
READWRITE_CMD = const(0x80)
MULTIPLEBYTE_CMD = const(0x40)
WHO_AM_I_ADDR = const(0x0F)
Reported by Pylint.
Line: 19
Column: 1
from micropython import const
from pyb import Pin
from pyb import SPI
READWRITE_CMD = const(0x80)
MULTIPLEBYTE_CMD = const(0x40)
WHO_AM_I_ADDR = const(0x0F)
OUT_X_ADDR = const(0x29)
Reported by Pylint.
Line: 42
Column: 1
LIS3DSH_CTRL_REG5_CONF = const(0b00000000)
class STAccel:
def __init__(self):
self.cs_pin = Pin("PE3", Pin.OUT_PP, Pin.PULL_NONE)
self.cs_pin.high()
self.spi = SPI(1, SPI.MASTER, baudrate=328125, polarity=0, phase=1, bits=8)
Reported by Pylint.
Line: 60
Column: 5
else:
raise Exception("LIS302DL or LIS3DSH accelerometer not present")
def convert_raw_to_g(self, x):
if x & 0x80:
x = x - 256
return x * self.sensitivity / 1000
def read_bytes(self, addr, nbytes):
Reported by Pylint.
Line: 60
Column: 5
else:
raise Exception("LIS302DL or LIS3DSH accelerometer not present")
def convert_raw_to_g(self, x):
if x & 0x80:
x = x - 256
return x * self.sensitivity / 1000
def read_bytes(self, addr, nbytes):
Reported by Pylint.
Line: 65
Column: 5
x = x - 256
return x * self.sensitivity / 1000
def read_bytes(self, addr, nbytes):
if nbytes > 1:
addr |= READWRITE_CMD | MULTIPLEBYTE_CMD
else:
addr |= READWRITE_CMD
self.cs_pin.low()
Reported by Pylint.
Line: 77
Column: 5
self.cs_pin.high()
return buf
def write_bytes(self, addr, buf):
if len(buf) > 1:
addr |= MULTIPLEBYTE_CMD
self.cs_pin.low()
self.spi.send(addr)
for b in buf:
Reported by Pylint.
Line: 82
Column: 13
addr |= MULTIPLEBYTE_CMD
self.cs_pin.low()
self.spi.send(addr)
for b in buf:
self.spi.send(b)
self.cs_pin.high()
def read_id(self):
return self.read_bytes(WHO_AM_I_ADDR, 1)[0]
Reported by Pylint.
Line: 86
Column: 5
self.spi.send(b)
self.cs_pin.high()
def read_id(self):
return self.read_bytes(WHO_AM_I_ADDR, 1)[0]
def x(self):
return self.convert_raw_to_g(self.read_bytes(OUT_X_ADDR, 1)[0])
Reported by Pylint.
tests/basics/class_delattr_setattr.py
17 issues
Line: 85
Column: 7
object.__setattr__(c, "a", 5)
super(C, c).__setattr__("b", 6)
print(c.a)
print(c.b)
try:
# attribute name must be string
object.__setattr__(c, 5, 5)
except TypeError:
Reported by Pylint.
Line: 10
Column: 5
del Test().noexist
except AttributeError:
print('SKIP')
raise SystemExit
# this class just prints the calls to see if they were executed
class A():
def __getattr__(self, attr):
print('get', attr)
Reported by Pylint.
Line: 56
Column: 1
a = B({"a":1, "b":2})
print(a.a, a.b)
a.a = 3
print(a.a, a.b)
del a.a
try:
print(a.a)
except AttributeError:
Reported by Pylint.
Line: 76
Column: 1
print("del", attr)
c = C()
c.a = 5
try:
print(c.a)
except AttributeError:
print("AttributeError")
Reported by Pylint.
Line: 1
Column: 1
# test __delattr__ and __setattr__
# feature test for __setattr__/__delattr__
try:
class Test():
def __delattr__(self, attr): pass
del Test().noexist
except AttributeError:
print('SKIP')
Reported by Pylint.
Line: 5
Column: 5
# feature test for __setattr__/__delattr__
try:
class Test():
def __delattr__(self, attr): pass
del Test().noexist
except AttributeError:
print('SKIP')
raise SystemExit
Reported by Pylint.
Line: 5
Column: 5
# feature test for __setattr__/__delattr__
try:
class Test():
def __delattr__(self, attr): pass
del Test().noexist
except AttributeError:
print('SKIP')
raise SystemExit
Reported by Pylint.
Line: 6
Column: 38
# feature test for __setattr__/__delattr__
try:
class Test():
def __delattr__(self, attr): pass
del Test().noexist
except AttributeError:
print('SKIP')
raise SystemExit
Reported by Pylint.
Line: 13
Column: 1
raise SystemExit
# this class just prints the calls to see if they were executed
class A():
def __getattr__(self, attr):
print('get', attr)
return 1
def __setattr__(self, attr, val):
print('set', attr, val)
Reported by Pylint.
Line: 13
Column: 1
raise SystemExit
# this class just prints the calls to see if they were executed
class A():
def __getattr__(self, attr):
print('get', attr)
return 1
def __setattr__(self, attr, val):
print('set', attr, val)
Reported by Pylint.
tests/micropython/viper_ptr16_load.py
17 issues
Line: 5
Column: 2
# only works on little endian machines
@micropython.viper
def get(src: ptr16) -> int:
return src[0]
@micropython.viper
Reported by Pylint.
Line: 6
Column: 14
@micropython.viper
def get(src: ptr16) -> int:
return src[0]
@micropython.viper
def get1(src: ptr16) -> int:
Reported by Pylint.
Line: 10
Column: 2
return src[0]
@micropython.viper
def get1(src: ptr16) -> int:
return src[1]
@micropython.viper
Reported by Pylint.
Line: 11
Column: 15
@micropython.viper
def get1(src: ptr16) -> int:
return src[1]
@micropython.viper
def memadd(src: ptr16, n: int) -> int:
Reported by Pylint.
Line: 15
Column: 2
return src[1]
@micropython.viper
def memadd(src: ptr16, n: int) -> int:
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 16
Column: 17
@micropython.viper
def memadd(src: ptr16, n: int) -> int:
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 23
Column: 2
return sum
@micropython.viper
def memadd2(src_in) -> int:
src = ptr16(src_in)
n = int(len(src_in)) >> 1
sum = 0
for i in range(n):
Reported by Pylint.
Line: 25
Column: 11
@micropython.viper
def memadd2(src_in) -> int:
src = ptr16(src_in)
n = int(len(src_in)) >> 1
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 17
Column: 5
@micropython.viper
def memadd(src: ptr16, n: int) -> int:
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 27
Column: 5
def memadd2(src_in) -> int:
src = ptr16(src_in)
n = int(len(src_in)) >> 1
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
tests/basics/del_global.py
17 issues
Line: 5
Column: 9
def do_del():
global x
del x
x = 1
print(x)
do_del()
try:
Reported by Pylint.
Line: 4
Column: 5
# del global
def do_del():
global x
del x
x = 1
print(x)
do_del()
Reported by Pylint.
Line: 16
Column: 1
print("NameError")
try:
do_del()
except: # NameError:
# FIXME uPy returns KeyError for this
print("NameError")
# delete globals using a list
Reported by Pylint.
Line: 17
Column: 3
try:
do_del()
except: # NameError:
# FIXME uPy returns KeyError for this
print("NameError")
# delete globals using a list
a = 1
Reported by Pylint.
Line: 1
Column: 1
# del global
def do_del():
global x
del x
x = 1
print(x)
do_del()
Reported by Pylint.
Line: 3
Column: 1
# del global
def do_del():
global x
del x
x = 1
print(x)
do_del()
Reported by Pylint.
Line: 4
Column: 5
# del global
def do_del():
global x
del x
x = 1
print(x)
do_del()
Reported by Pylint.
Line: 7
Column: 1
global x
del x
x = 1
print(x)
do_del()
try:
print(x)
except NameError:
Reported by Pylint.
Line: 22
Column: 1
# delete globals using a list
a = 1
del (a,)
try:
print(a)
except NameError:
print("NameError")
Reported by Pylint.
Line: 29
Column: 1
except NameError:
print("NameError")
a = 2
b = 3
del (a, b)
try:
print(a)
except NameError:
Reported by Pylint.
tests/extmod/uctypes_native_le.py
17 issues
Line: 4
Column: 1
# This test is exactly like uctypes_le.py, but uses native structure layout.
# Codepaths for packed vs native structures are different. This test only works
# on little-endian machine (no matter if 32 or 64 bit).
import usys
try:
import uctypes
except ImportError:
print("SKIP")
Reported by Pylint.
Line: 10
Column: 5
import uctypes
except ImportError:
print("SKIP")
raise SystemExit
if usys.byteorder != "little":
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 44
Column: 5
assert S.sub.b0, S.sub.b1 == (0x30, 0x31)
try:
S[0]
assert False, "Can't index struct"
except TypeError:
print("TypeError")
print("arr:", S.arr[0], S.arr[1])
Reported by Pylint.
Line: 57
Column: 5
try:
S.arr[2]
assert False, "Out of bounds index"
except IndexError:
print("IndexError")
print("bf:", S.bitf0, S.bitf1)
Reported by Pylint.
Line: 1
Column: 1
# This test is exactly like uctypes_le.py, but uses native structure layout.
# Codepaths for packed vs native structures are different. This test only works
# on little-endian machine (no matter if 32 or 64 bit).
import usys
try:
import uctypes
except ImportError:
print("SKIP")
Reported by Pylint.
Line: 38
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# print(S)
print(hex(S.s0))
assert hex(S.s0) == "0x3130"
# print(S.sub.b0)
print(S.sub.b0, S.sub.b1)
assert S.sub.b0, S.sub.b1 == (0x30, 0x31)
try:
Reported by Bandit.
Line: 41
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert hex(S.s0) == "0x3130"
# print(S.sub.b0)
print(S.sub.b0, S.sub.b1)
assert S.sub.b0, S.sub.b1 == (0x30, 0x31)
try:
S[0]
assert False, "Can't index struct"
except TypeError:
Reported by Bandit.
Line: 45
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
try:
S[0]
assert False, "Can't index struct"
except TypeError:
print("TypeError")
print("arr:", S.arr[0], S.arr[1])
assert (S.arr[0], S.arr[1]) == (0x30, 0x31)
Reported by Bandit.
Line: 50
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
print("TypeError")
print("arr:", S.arr[0], S.arr[1])
assert (S.arr[0], S.arr[1]) == (0x30, 0x31)
print("arr of struct:", S.arr2[0].b, S.arr2[1].b)
assert (S.arr2[0].b, S.arr2[1].b) == (0x30, 0x31)
Reported by Bandit.
Line: 53
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert (S.arr[0], S.arr[1]) == (0x30, 0x31)
print("arr of struct:", S.arr2[0].b, S.arr2[1].b)
assert (S.arr2[0].b, S.arr2[1].b) == (0x30, 0x31)
try:
S.arr[2]
assert False, "Out of bounds index"
Reported by Bandit.
tests/micropython/viper_ptr32_load.py
17 issues
Line: 4
Column: 2
# test loading from ptr32 type
@micropython.viper
def get(src: ptr32) -> int:
return src[0]
@micropython.viper
Reported by Pylint.
Line: 5
Column: 14
@micropython.viper
def get(src: ptr32) -> int:
return src[0]
@micropython.viper
def get1(src: ptr32) -> int:
Reported by Pylint.
Line: 9
Column: 2
return src[0]
@micropython.viper
def get1(src: ptr32) -> int:
return src[1]
@micropython.viper
Reported by Pylint.
Line: 10
Column: 15
@micropython.viper
def get1(src: ptr32) -> int:
return src[1]
@micropython.viper
def memadd(src: ptr32, n: int) -> int:
Reported by Pylint.
Line: 14
Column: 2
return src[1]
@micropython.viper
def memadd(src: ptr32, n: int) -> int:
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 15
Column: 17
@micropython.viper
def memadd(src: ptr32, n: int) -> int:
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 22
Column: 2
return sum
@micropython.viper
def memadd2(src_in) -> int:
src = ptr32(src_in)
n = int(len(src_in)) >> 2
sum = 0
for i in range(n):
Reported by Pylint.
Line: 24
Column: 11
@micropython.viper
def memadd2(src_in) -> int:
src = ptr32(src_in)
n = int(len(src_in)) >> 2
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 16
Column: 5
@micropython.viper
def memadd(src: ptr32, n: int) -> int:
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
Line: 26
Column: 5
def memadd2(src_in) -> int:
src = ptr32(src_in)
n = int(len(src_in)) >> 2
sum = 0
for i in range(n):
sum += src[i]
return sum
Reported by Pylint.
tests/basics/try_finally2.py
17 issues
Line: 3
Column: 11
# check that the Python stack does not overflow when the finally
# block itself uses more stack than the rest of the function
def f1(a, b):
pass
def test1():
val = 1
try:
raise ValueError()
finally:
Reported by Pylint.
Line: 3
Column: 8
# check that the Python stack does not overflow when the finally
# block itself uses more stack than the rest of the function
def f1(a, b):
pass
def test1():
val = 1
try:
raise ValueError()
finally:
Reported by Pylint.
Line: 18
Column: 14
pass
# same as above but with 3 args instead of 2, to use an extra stack entry
def f2(a, b, c):
pass
def test2():
val = 1
try:
raise ValueError()
Reported by Pylint.
Line: 18
Column: 11
pass
# same as above but with 3 args instead of 2, to use an extra stack entry
def f2(a, b, c):
pass
def test2():
val = 1
try:
raise ValueError()
Reported by Pylint.
Line: 18
Column: 8
pass
# same as above but with 3 args instead of 2, to use an extra stack entry
def f2(a, b, c):
pass
def test2():
val = 1
try:
raise ValueError()
Reported by Pylint.
Line: 1
Column: 1
# check that the Python stack does not overflow when the finally
# block itself uses more stack than the rest of the function
def f1(a, b):
pass
def test1():
val = 1
try:
raise ValueError()
finally:
Reported by Pylint.
Line: 3
Column: 1
# check that the Python stack does not overflow when the finally
# block itself uses more stack than the rest of the function
def f1(a, b):
pass
def test1():
val = 1
try:
raise ValueError()
finally:
Reported by Pylint.
Line: 3
Column: 1
# check that the Python stack does not overflow when the finally
# block itself uses more stack than the rest of the function
def f1(a, b):
pass
def test1():
val = 1
try:
raise ValueError()
finally:
Reported by Pylint.
Line: 3
Column: 1
# check that the Python stack does not overflow when the finally
# block itself uses more stack than the rest of the function
def f1(a, b):
pass
def test1():
val = 1
try:
raise ValueError()
finally:
Reported by Pylint.
Line: 3
Column: 1
# check that the Python stack does not overflow when the finally
# block itself uses more stack than the rest of the function
def f1(a, b):
pass
def test1():
val = 1
try:
raise ValueError()
finally:
Reported by Pylint.
tests/basics/gen_yield_from_ducktype.py
16 issues
Line: 57
Column: 5
raise StopIteration(42)
def gen4():
global ret
ret = yield from MyIter()
1//0
ret = None
try:
Reported by Pylint.
Line: 59
Column: 5
def gen4():
global ret
ret = yield from MyIter()
1//0
ret = None
try:
print(list(gen4()))
except ZeroDivisionError:
Reported by Pylint.
Line: 1
Column: 1
class MyGen:
def __init__(self):
self.v = 0
def __iter__(self):
return self
def __next__(self):
Reported by Pylint.
Line: 1
Column: 1
class MyGen:
def __init__(self):
self.v = 0
def __iter__(self):
return self
def __next__(self):
Reported by Pylint.
Line: 4
Column: 9
class MyGen:
def __init__(self):
self.v = 0
def __iter__(self):
return self
def __next__(self):
Reported by Pylint.
Line: 15
Column: 1
raise StopIteration
return self.v
def gen():
yield from MyGen()
def gen2():
yield from gen()
Reported by Pylint.
Line: 18
Column: 1
def gen():
yield from MyGen()
def gen2():
yield from gen()
print(list(gen()))
print(list(gen2()))
Reported by Pylint.
Line: 25
Column: 1
print(list(gen2()))
class Incrementer:
def __iter__(self):
return self
def __next__(self):
Reported by Pylint.
Line: 33
Column: 5
def __next__(self):
return self.send(None)
def send(self, val):
if val is None:
return "Incrementer initialized"
return val + 1
def gen3():
Reported by Pylint.
Line: 33
Column: 5
def __next__(self):
return self.send(None)
def send(self, val):
if val is None:
return "Incrementer initialized"
return val + 1
def gen3():
Reported by Pylint.