The following issues were found
tests/extmod/machine_pulse.py
17 issues
Line: 6
Column: 5
import umachine as machine
except ImportError:
import machine
machine.PinBase
machine.time_pulse_us
except:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 7
Column: 5
except ImportError:
import machine
machine.PinBase
machine.time_pulse_us
except:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 10
Column: 5
machine.time_pulse_us
except:
print("SKIP")
raise SystemExit
class ConstPin(machine.PinBase):
def __init__(self, value):
self.v = value
Reported by Pylint.
Line: 1
Column: 1
try:
try:
import umachine as machine
except ImportError:
import machine
machine.PinBase
machine.time_pulse_us
except:
print("SKIP")
Reported by Pylint.
Line: 13
Column: 1
raise SystemExit
class ConstPin(machine.PinBase):
def __init__(self, value):
self.v = value
def value(self, v=None):
if v is None:
Reported by Pylint.
Line: 13
Column: 1
raise SystemExit
class ConstPin(machine.PinBase):
def __init__(self, value):
self.v = value
def value(self, v=None):
if v is None:
Reported by Pylint.
Line: 15
Column: 9
class ConstPin(machine.PinBase):
def __init__(self, value):
self.v = value
def value(self, v=None):
if v is None:
return self.v
else:
Reported by Pylint.
Line: 17
Column: 5
def __init__(self, value):
self.v = value
def value(self, v=None):
if v is None:
return self.v
else:
self.v = v
Reported by Pylint.
Line: 17
Column: 5
def __init__(self, value):
self.v = value
def value(self, v=None):
if v is None:
return self.v
else:
self.v = v
Reported by Pylint.
Line: 17
Column: 5
def __init__(self, value):
self.v = value
def value(self, v=None):
if v is None:
return self.v
else:
self.v = v
Reported by Pylint.
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/basics/special_comparisons.py
17 issues
Line: 28
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
def test(s):
print(s)
print(eval(s))
for x in 'abcd':
for y in 'abcd':
test('{} == {}'.format(x,y))
test('{} != {}'.format(x,y))
Reported by Bandit.
Line: 28
Column: 11
def test(s):
print(s)
print(eval(s))
for x in 'abcd':
for y in 'abcd':
test('{} == {}'.format(x,y))
test('{} != {}'.format(x,y))
Reported by Pylint.
Line: 1
Column: 1
class A:
def __eq__(self, other):
print("A __eq__ called")
return True
class B:
def __ne__(self, other):
print("B __ne__ called")
return True
Reported by Pylint.
Line: 1
Column: 1
class A:
def __eq__(self, other):
print("A __eq__ called")
return True
class B:
def __ne__(self, other):
print("B __ne__ called")
return True
Reported by Pylint.
Line: 1
Column: 1
class A:
def __eq__(self, other):
print("A __eq__ called")
return True
class B:
def __ne__(self, other):
print("B __ne__ called")
return True
Reported by Pylint.
Line: 1
Column: 1
class A:
def __eq__(self, other):
print("A __eq__ called")
return True
class B:
def __ne__(self, other):
print("B __ne__ called")
return True
Reported by Pylint.
Line: 6
Column: 1
print("A __eq__ called")
return True
class B:
def __ne__(self, other):
print("B __ne__ called")
return True
class C:
Reported by Pylint.
Line: 6
Column: 1
print("A __eq__ called")
return True
class B:
def __ne__(self, other):
print("B __ne__ called")
return True
class C:
Reported by Pylint.
Line: 6
Column: 1
print("A __eq__ called")
return True
class B:
def __ne__(self, other):
print("B __ne__ called")
return True
class C:
Reported by Pylint.
Line: 11
Column: 1
print("B __ne__ called")
return True
class C:
def __eq__(self, other):
print("C __eq__ called")
return False
class D:
Reported by Pylint.
examples/bluetooth/ble_temperature.py
17 issues
Line: 6
Column: 1
# The sensor's local value updates every second, and it will notify
# any connected central every 10 seconds.
import bluetooth
import random
import struct
import time
from ble_advertising import advertising_payload
Reported by Pylint.
Line: 12
Column: 1
import time
from ble_advertising import advertising_payload
from micropython import const
_IRQ_CENTRAL_CONNECT = const(1)
_IRQ_CENTRAL_DISCONNECT = const(2)
_IRQ_GATTS_INDICATE_DONE = const(20)
Reported by Pylint.
Line: 93
Column: 9
temp.set_temperature(t, notify=i == 0, indicate=False)
# Random walk the temperature.
t += random.uniform(-0.5, 0.5)
time.sleep_ms(1000)
if __name__ == "__main__":
demo()
Reported by Pylint.
Line: 61
Column: 40
# Start advertising again to allow a new connection.
self._advertise()
elif event == _IRQ_GATTS_INDICATE_DONE:
conn_handle, value_handle, status = data
def set_temperature(self, temp_deg_c, notify=False, indicate=False):
# Data is sint16 in degrees Celsius with a resolution of 0.01 degrees Celsius.
# Write the local value, ready for a central to read.
self._ble.gatts_write(self._handle, struct.pack("<h", int(temp_deg_c * 100)))
Reported by Pylint.
Line: 61
Column: 26
# Start advertising again to allow a new connection.
self._advertise()
elif event == _IRQ_GATTS_INDICATE_DONE:
conn_handle, value_handle, status = data
def set_temperature(self, temp_deg_c, notify=False, indicate=False):
# Data is sint16 in degrees Celsius with a resolution of 0.01 degrees Celsius.
# Write the local value, ready for a central to read.
self._ble.gatts_write(self._handle, struct.pack("<h", int(temp_deg_c * 100)))
Reported by Pylint.
Line: 1
Column: 1
# This example demonstrates a simple temperature sensor peripheral.
#
# The sensor's local value updates every second, and it will notify
# any connected central every 10 seconds.
import bluetooth
import random
import struct
import time
Reported by Pylint.
Line: 7
Column: 1
# any connected central every 10 seconds.
import bluetooth
import random
import struct
import time
from ble_advertising import advertising_payload
from micropython import const
Reported by Pylint.
Line: 8
Column: 1
import bluetooth
import random
import struct
import time
from ble_advertising import advertising_payload
from micropython import const
Reported by Pylint.
Line: 9
Column: 1
import bluetooth
import random
import struct
import time
from ble_advertising import advertising_payload
from micropython import const
_IRQ_CENTRAL_CONNECT = const(1)
Reported by Pylint.
Line: 12
Column: 1
import time
from ble_advertising import advertising_payload
from micropython import const
_IRQ_CENTRAL_CONNECT = const(1)
_IRQ_CENTRAL_DISCONNECT = const(2)
_IRQ_GATTS_INDICATE_DONE = const(20)
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.
examples/bluetooth/ble_simple_peripheral.py
17 issues
Line: 3
Column: 1
# This example demonstrates a UART periperhal.
import bluetooth
import random
import struct
import time
from ble_advertising import advertising_payload
from micropython import const
Reported by Pylint.
Line: 9
Column: 1
import time
from ble_advertising import advertising_payload
from micropython import const
_IRQ_CENTRAL_CONNECT = const(1)
_IRQ_CENTRAL_DISCONNECT = const(2)
_IRQ_GATTS_WRITE = const(3)
Reported by Pylint.
Line: 97
Column: 9
print("TX", data)
p.send(data)
i += 1
time.sleep_ms(100)
if __name__ == "__main__":
demo()
Reported by Pylint.
Line: 4
Column: 1
# This example demonstrates a UART periperhal.
import bluetooth
import random
import struct
import time
from ble_advertising import advertising_payload
from micropython import const
Reported by Pylint.
Line: 5
Column: 1
import bluetooth
import random
import struct
import time
from ble_advertising import advertising_payload
from micropython import const
Reported by Pylint.
Line: 1
Column: 1
# This example demonstrates a UART periperhal.
import bluetooth
import random
import struct
import time
from ble_advertising import advertising_payload
from micropython import const
Reported by Pylint.
Line: 4
Column: 1
# This example demonstrates a UART periperhal.
import bluetooth
import random
import struct
import time
from ble_advertising import advertising_payload
from micropython import const
Reported by Pylint.
Line: 5
Column: 1
import bluetooth
import random
import struct
import time
from ble_advertising import advertising_payload
from micropython import const
Reported by Pylint.
Line: 6
Column: 1
import bluetooth
import random
import struct
import time
from ble_advertising import advertising_payload
from micropython import const
_IRQ_CENTRAL_CONNECT = const(1)
Reported by Pylint.
Line: 9
Column: 1
import time
from ble_advertising import advertising_payload
from micropython import const
_IRQ_CENTRAL_CONNECT = const(1)
_IRQ_CENTRAL_DISCONNECT = const(2)
_IRQ_GATTS_WRITE = const(3)
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/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.
py/makeqstrdata.py
17 issues
Line: 19
Column: 5
if platform.python_version_tuple()[0] == "2":
bytes_cons = lambda val, enc=None: bytearray(val)
from htmlentitydefs import codepoint2name
elif platform.python_version_tuple()[0] == "3":
bytes_cons = bytes
from html.entities import codepoint2name
# end compatibility code
Reported by Pylint.
Line: 227
Column: 5
# this must match the equivalent function in qstr.c
def compute_hash(qstr, bytes_hash):
hash = 5381
for b in qstr:
hash = (hash * 33) ^ b
# Make sure that valid hash is never zero, zero means "hash not computed"
return (hash & ((1 << (8 * bytes_hash)) - 1)) or 1
Reported by Pylint.
Line: 358
Column: 9
)
# go through each qstr and print it out
for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]):
qbytes = make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr)
print("QDEF(MP_QSTR_%s, %s)" % (ident, qbytes))
def do_work(infiles):
Reported by Pylint.
Line: 21
Column: 5
bytes_cons = lambda val, enc=None: bytearray(val)
from htmlentitydefs import codepoint2name
elif platform.python_version_tuple()[0] == "3":
bytes_cons = bytes
from html.entities import codepoint2name
# end compatibility code
codepoint2name[ord("-")] = "hyphen"
Reported by Pylint.
Line: 226
Column: 1
]
# this must match the equivalent function in qstr.c
def compute_hash(qstr, bytes_hash):
hash = 5381
for b in qstr:
hash = (hash * 33) ^ b
# Make sure that valid hash is never zero, zero means "hash not computed"
return (hash & ((1 << (8 * bytes_hash)) - 1)) or 1
Reported by Pylint.
Line: 228
Column: 9
# this must match the equivalent function in qstr.c
def compute_hash(qstr, bytes_hash):
hash = 5381
for b in qstr:
hash = (hash * 33) ^ b
# Make sure that valid hash is never zero, zero means "hash not computed"
return (hash & ((1 << (8 * bytes_hash)) - 1)) or 1
Reported by Pylint.
Line: 234
Column: 1
return (hash & ((1 << (8 * bytes_hash)) - 1)) or 1
def qstr_escape(qst):
def esc_char(m):
c = ord(m.group(0))
try:
name = codepoint2name[c]
except KeyError:
Reported by Pylint.
Line: 235
Column: 5
def qstr_escape(qst):
def esc_char(m):
c = ord(m.group(0))
try:
name = codepoint2name[c]
except KeyError:
name = "0x%02x" % c
Reported by Pylint.
Line: 236
Column: 9
def qstr_escape(qst):
def esc_char(m):
c = ord(m.group(0))
try:
name = codepoint2name[c]
except KeyError:
name = "0x%02x" % c
return "_" + name + "_"
Reported by Pylint.
Line: 246
Column: 1
return re.sub(r"[^A-Za-z0-9_]", esc_char, qst)
def parse_input_headers(infiles):
qcfgs = {}
qstrs = {}
# add static qstrs
for qstr in static_qstr_list:
Reported by Pylint.