The following issues were found
tests/micropython/viper_with.py
14 issues
Line: 16
Column: 2
# basic with
@micropython.viper
def f():
with C():
print(1)
Reported by Pylint.
Line: 25
Column: 2
f()
# nested with and try-except
@micropython.viper
def f():
try:
with C():
print(1)
fail
Reported by Pylint.
Line: 26
Column: 1
# nested with and try-except
@micropython.viper
def f():
try:
with C():
print(1)
fail
print(2)
Reported by Pylint.
Line: 30
Column: 13
try:
with C():
print(1)
fail
print(2)
except NameError:
print("NameError")
Reported by Pylint.
Line: 1
Column: 1
# test with handling within a viper function
class C:
def __init__(self):
print("__init__")
def __enter__(self):
print("__enter__")
Reported by Pylint.
Line: 4
Column: 1
# test with handling within a viper function
class C:
def __init__(self):
print("__init__")
def __enter__(self):
print("__enter__")
Reported by Pylint.
Line: 4
Column: 1
# test with handling within a viper function
class C:
def __init__(self):
print("__init__")
def __enter__(self):
print("__enter__")
Reported by Pylint.
Line: 11
Column: 5
def __enter__(self):
print("__enter__")
def __exit__(self, a, b, c):
print("__exit__", a, b, c)
# basic with
@micropython.viper
Reported by Pylint.
Line: 11
Column: 5
def __enter__(self):
print("__enter__")
def __exit__(self, a, b, c):
print("__exit__", a, b, c)
# basic with
@micropython.viper
Reported by Pylint.
Line: 11
Column: 5
def __enter__(self):
print("__enter__")
def __exit__(self, a, b, c):
print("__exit__", a, b, c)
# basic with
@micropython.viper
Reported by Pylint.
tests/basics/equal_class.py
14 issues
Line: 1
Column: 1
# test equality for classes/instances to other types
class A:
pass
class B:
pass
class C(A):
Reported by Pylint.
Line: 3
Column: 1
# test equality for classes/instances to other types
class A:
pass
class B:
pass
class C(A):
Reported by Pylint.
Line: 3
Column: 1
# test equality for classes/instances to other types
class A:
pass
class B:
pass
class C(A):
Reported by Pylint.
Line: 3
Column: 1
# test equality for classes/instances to other types
class A:
pass
class B:
pass
class C(A):
Reported by Pylint.
Line: 6
Column: 1
class A:
pass
class B:
pass
class C(A):
pass
Reported by Pylint.
Line: 6
Column: 1
class A:
pass
class B:
pass
class C(A):
pass
Reported by Pylint.
Line: 6
Column: 1
class A:
pass
class B:
pass
class C(A):
pass
Reported by Pylint.
Line: 9
Column: 1
class B:
pass
class C(A):
pass
print(A == None)
print(None == A)
Reported by Pylint.
Line: 9
Column: 1
class B:
pass
class C(A):
pass
print(A == None)
print(None == A)
Reported by Pylint.
Line: 9
Column: 1
class B:
pass
class C(A):
pass
print(A == None)
print(None == A)
Reported by Pylint.
tests/extmod/ticks_diff.py
14 issues
Line: 5
Column: 5
from utime import ticks_diff, ticks_add
except ImportError:
print("SKIP")
raise SystemExit
MAX = ticks_add(0, -1)
# Should be done like this to avoid small int overflow
MODULO_HALF = MAX // 2 + 1
Reported by Pylint.
Line: 1
Column: 1
try:
from utime import ticks_diff, ticks_add
except ImportError:
print("SKIP")
raise SystemExit
MAX = ticks_add(0, -1)
# Should be done like this to avoid small int overflow
MODULO_HALF = MAX // 2 + 1
Reported by Pylint.
Line: 15
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# if ticks_diff(a, b) = c,
# then ticks_diff(b, a) = -c
assert ticks_diff(1, 0) == 1, ticks_diff(1, 0)
assert ticks_diff(0, 1) == -1
assert ticks_diff(0, MAX) == 1
assert ticks_diff(MAX, 0) == -1
Reported by Bandit.
Line: 16
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# then ticks_diff(b, a) = -c
assert ticks_diff(1, 0) == 1, ticks_diff(1, 0)
assert ticks_diff(0, 1) == -1
assert ticks_diff(0, MAX) == 1
assert ticks_diff(MAX, 0) == -1
assert ticks_diff(0, MAX - 1) == 2
Reported by Bandit.
Line: 18
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert ticks_diff(1, 0) == 1, ticks_diff(1, 0)
assert ticks_diff(0, 1) == -1
assert ticks_diff(0, MAX) == 1
assert ticks_diff(MAX, 0) == -1
assert ticks_diff(0, MAX - 1) == 2
# Maximum "positive" distance
Reported by Bandit.
Line: 19
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert ticks_diff(0, 1) == -1
assert ticks_diff(0, MAX) == 1
assert ticks_diff(MAX, 0) == -1
assert ticks_diff(0, MAX - 1) == 2
# Maximum "positive" distance
assert ticks_diff(MODULO_HALF, 1) == MODULO_HALF - 1, ticks_diff(MODULO_HALF, 1)
Reported by Bandit.
Line: 21
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert ticks_diff(0, MAX) == 1
assert ticks_diff(MAX, 0) == -1
assert ticks_diff(0, MAX - 1) == 2
# Maximum "positive" distance
assert ticks_diff(MODULO_HALF, 1) == MODULO_HALF - 1, ticks_diff(MODULO_HALF, 1)
# Step further, and it becomes a negative distance
assert ticks_diff(MODULO_HALF, 0) == -MODULO_HALF
Reported by Bandit.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert ticks_diff(0, MAX - 1) == 2
# Maximum "positive" distance
assert ticks_diff(MODULO_HALF, 1) == MODULO_HALF - 1, ticks_diff(MODULO_HALF, 1)
# Step further, and it becomes a negative distance
assert ticks_diff(MODULO_HALF, 0) == -MODULO_HALF
# Offsetting that in either direction doesn't affect the result
off = 100
Reported by Bandit.
Line: 26
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# Maximum "positive" distance
assert ticks_diff(MODULO_HALF, 1) == MODULO_HALF - 1, ticks_diff(MODULO_HALF, 1)
# Step further, and it becomes a negative distance
assert ticks_diff(MODULO_HALF, 0) == -MODULO_HALF
# Offsetting that in either direction doesn't affect the result
off = 100
# Cheating and skipping to use ticks_add() when we know there's no wraparound
# Real apps should use always it.
Reported by Bandit.
Line: 29
Column: 1
assert ticks_diff(MODULO_HALF, 0) == -MODULO_HALF
# Offsetting that in either direction doesn't affect the result
off = 100
# Cheating and skipping to use ticks_add() when we know there's no wraparound
# Real apps should use always it.
assert ticks_diff(MODULO_HALF + off, 1 + off) == MODULO_HALF - 1
assert ticks_diff(MODULO_HALF + off, 0 + off) == -MODULO_HALF
assert ticks_diff(MODULO_HALF - off, ticks_add(1, -off)) == MODULO_HALF - 1
Reported by Pylint.
tests/inlineasm/asmspecialregs.py
13 issues
Line: 1
Column: 2
@micropython.asm_thumb
def getIPSR():
mrs(r0, IPSR)
@micropython.asm_thumb
def getBASEPRI():
mrs(r0, BASEPRI)
Reported by Pylint.
Line: 3
Column: 13
@micropython.asm_thumb
def getIPSR():
mrs(r0, IPSR)
@micropython.asm_thumb
def getBASEPRI():
mrs(r0, BASEPRI)
Reported by Pylint.
Line: 3
Column: 9
@micropython.asm_thumb
def getIPSR():
mrs(r0, IPSR)
@micropython.asm_thumb
def getBASEPRI():
mrs(r0, BASEPRI)
Reported by Pylint.
Line: 3
Column: 5
@micropython.asm_thumb
def getIPSR():
mrs(r0, IPSR)
@micropython.asm_thumb
def getBASEPRI():
mrs(r0, BASEPRI)
Reported by Pylint.
Line: 6
Column: 2
mrs(r0, IPSR)
@micropython.asm_thumb
def getBASEPRI():
mrs(r0, BASEPRI)
print(getBASEPRI())
Reported by Pylint.
Line: 8
Column: 5
@micropython.asm_thumb
def getBASEPRI():
mrs(r0, BASEPRI)
print(getBASEPRI())
print(getIPSR())
Reported by Pylint.
Line: 8
Column: 9
@micropython.asm_thumb
def getBASEPRI():
mrs(r0, BASEPRI)
print(getBASEPRI())
print(getIPSR())
Reported by Pylint.
Line: 8
Column: 13
@micropython.asm_thumb
def getBASEPRI():
mrs(r0, BASEPRI)
print(getBASEPRI())
print(getIPSR())
Reported by Pylint.
Line: 1
Column: 1
@micropython.asm_thumb
def getIPSR():
mrs(r0, IPSR)
@micropython.asm_thumb
def getBASEPRI():
mrs(r0, BASEPRI)
Reported by Pylint.
Line: 2
Column: 1
@micropython.asm_thumb
def getIPSR():
mrs(r0, IPSR)
@micropython.asm_thumb
def getBASEPRI():
mrs(r0, BASEPRI)
Reported by Pylint.
tests/basics/decorator.py
13 issues
Line: 3
Column: 9
# test decorators
def dec(f):
print('dec')
return f
def dec_arg(x):
print(x)
return lambda f:f
Reported by Pylint.
Line: 1
Column: 1
# test decorators
def dec(f):
print('dec')
return f
def dec_arg(x):
print(x)
return lambda f:f
Reported by Pylint.
Line: 3
Column: 1
# test decorators
def dec(f):
print('dec')
return f
def dec_arg(x):
print(x)
return lambda f:f
Reported by Pylint.
Line: 3
Column: 1
# test decorators
def dec(f):
print('dec')
return f
def dec_arg(x):
print(x)
return lambda f:f
Reported by Pylint.
Line: 7
Column: 1
print('dec')
return f
def dec_arg(x):
print(x)
return lambda f:f
# plain decorator
@dec
Reported by Pylint.
Line: 7
Column: 1
print('dec')
return f
def dec_arg(x):
print(x)
return lambda f:f
# plain decorator
@dec
Reported by Pylint.
Line: 13
Column: 1
# plain decorator
@dec
def f():
pass
# decorator with arg
@dec_arg('dec_arg')
def g():
Reported by Pylint.
Line: 13
Column: 1
# plain decorator
@dec
def f():
pass
# decorator with arg
@dec_arg('dec_arg')
def g():
Reported by Pylint.
Line: 18
Column: 1
# decorator with arg
@dec_arg('dec_arg')
def g():
pass
# decorator of class
@dec
class A:
Reported by Pylint.
Line: 18
Column: 1
# decorator with arg
@dec_arg('dec_arg')
def g():
pass
# decorator of class
@dec
class A:
Reported by Pylint.
ports/esp8266/modules/inisetup.py
13 issues
Line: 1
Column: 1
import uos
import network
from flashbdev import bdev
def wifi():
import ubinascii
ap_if = network.WLAN(network.AP_IF)
Reported by Pylint.
Line: 2
Column: 1
import uos
import network
from flashbdev import bdev
def wifi():
import ubinascii
ap_if = network.WLAN(network.AP_IF)
Reported by Pylint.
Line: 7
Column: 5
def wifi():
import ubinascii
ap_if = network.WLAN(network.AP_IF)
essid = b"MicroPython-%s" % ubinascii.hexlify(ap_if.config("mac")[-3:])
ap_if.config(essid=essid, authmode=network.AUTH_WPA_WPA2_PSK, password=b"micropythoN")
Reported by Pylint.
Line: 1
Column: 1
import uos
import network
from flashbdev import bdev
def wifi():
import ubinascii
ap_if = network.WLAN(network.AP_IF)
Reported by Pylint.
Line: 6
Column: 1
from flashbdev import bdev
def wifi():
import ubinascii
ap_if = network.WLAN(network.AP_IF)
essid = b"MicroPython-%s" % ubinascii.hexlify(ap_if.config("mac")[-3:])
ap_if.config(essid=essid, authmode=network.AUTH_WPA_WPA2_PSK, password=b"micropythoN")
Reported by Pylint.
Line: 7
Column: 5
def wifi():
import ubinascii
ap_if = network.WLAN(network.AP_IF)
essid = b"MicroPython-%s" % ubinascii.hexlify(ap_if.config("mac")[-3:])
ap_if.config(essid=essid, authmode=network.AUTH_WPA_WPA2_PSK, password=b"micropythoN")
Reported by Pylint.
Line: 14
Column: 1
ap_if.config(essid=essid, authmode=network.AUTH_WPA_WPA2_PSK, password=b"micropythoN")
def check_bootsec():
buf = bytearray(bdev.SEC_SIZE)
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
Reported by Pylint.
Line: 14
Column: 1
ap_if.config(essid=essid, authmode=network.AUTH_WPA_WPA2_PSK, password=b"micropythoN")
def check_bootsec():
buf = bytearray(bdev.SEC_SIZE)
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
Reported by Pylint.
Line: 18
Column: 9
buf = bytearray(bdev.SEC_SIZE)
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
empty = False
break
if empty:
return True
Reported by Pylint.
Line: 27
Column: 1
fs_corrupted()
def fs_corrupted():
import time
while 1:
print(
"""\
Reported by Pylint.
tests/basics/subclass_native1.py
13 issues
Line: 6
Column: 1
a = mylist([1, 2, 5])
# Test setting instance attr
a.attr = "something"
# Test base type __str__
print(a)
# Test getting instance attr
print(a.attr)
# Test base type ->subscr
Reported by Pylint.
Line: 21
Column: 3
# Test binary op of base type, with 2nd arg being raw base type
print(a + [20, 30, 40])
# Test binary op of base type, with 2nd arg being same class as 1st arg
# TODO: Faults
#print(a + a)
def foo():
print("hello from foo")
Reported by Pylint.
Line: 36
Column: 9
# multiple bases with layout conflict
try:
class A(type, tuple):
None
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 1
Column: 1
class mylist(list):
pass
a = mylist([1, 2, 5])
# Test setting instance attr
a.attr = "something"
# Test base type __str__
print(a)
# Test getting instance attr
Reported by Pylint.
Line: 1
Column: 1
class mylist(list):
pass
a = mylist([1, 2, 5])
# Test setting instance attr
a.attr = "something"
# Test base type __str__
print(a)
# Test getting instance attr
Reported by Pylint.
Line: 1
Column: 1
class mylist(list):
pass
a = mylist([1, 2, 5])
# Test setting instance attr
a.attr = "something"
# Test base type __str__
print(a)
# Test getting instance attr
Reported by Pylint.
Line: 24
Column: 1
# TODO: Faults
#print(a + a)
def foo():
print("hello from foo")
try:
class myfunc(type(foo)):
pass
Reported by Pylint.
Line: 24
Column: 1
# TODO: Faults
#print(a + a)
def foo():
print("hello from foo")
try:
class myfunc(type(foo)):
pass
Reported by Pylint.
Line: 28
Column: 5
print("hello from foo")
try:
class myfunc(type(foo)):
pass
except TypeError:
print("TypeError")
# multiple bases with layout conflict
Reported by Pylint.
Line: 28
Column: 5
print("hello from foo")
try:
class myfunc(type(foo)):
pass
except TypeError:
print("TypeError")
# multiple bases with layout conflict
Reported by Pylint.
tests/basics/with1.py
13 issues
Line: 7
Column: 24
print("__enter__")
return self
def __exit__(self, a, b, c):
print("__exit__", repr(a), repr(b))
with CtxMgr() as a:
print(isinstance(a, CtxMgr))
Reported by Pylint.
Line: 27
Column: 24
print("__enter__")
return self
def __exit__(self, a, b, c):
print("__exit__", repr(a), repr(b))
return True
try:
with CtxMgr2() as a:
Reported by Pylint.
Line: 50
Column: 13
try:
try:
raise ValueError
print("No ValueError3")
finally:
print("finally1")
finally:
print("finally2")
Reported by Pylint.
Line: 63
Column: 21
try:
try:
raise ValueError
print("No ValueError3")
finally:
print("finally1")
finally:
print("finally2")
finally:
Reported by Pylint.
Line: 1
Column: 1
class CtxMgr:
def __enter__(self):
print("__enter__")
return self
def __exit__(self, a, b, c):
print("__exit__", repr(a), repr(b))
Reported by Pylint.
Line: 1
Column: 1
class CtxMgr:
def __enter__(self):
print("__enter__")
return self
def __exit__(self, a, b, c):
print("__exit__", repr(a), repr(b))
Reported by Pylint.
Line: 7
Column: 5
print("__enter__")
return self
def __exit__(self, a, b, c):
print("__exit__", repr(a), repr(b))
with CtxMgr() as a:
print(isinstance(a, CtxMgr))
Reported by Pylint.
Line: 7
Column: 5
print("__enter__")
return self
def __exit__(self, a, b, c):
print("__exit__", repr(a), repr(b))
with CtxMgr() as a:
print(isinstance(a, CtxMgr))
Reported by Pylint.
Line: 7
Column: 5
print("__enter__")
return self
def __exit__(self, a, b, c):
print("__exit__", repr(a), repr(b))
with CtxMgr() as a:
print(isinstance(a, CtxMgr))
Reported by Pylint.
Line: 21
Column: 1
print("ValueError")
class CtxMgr2:
def __enter__(self):
print("__enter__")
return self
Reported by Pylint.
tests/extmod/websocket_basic.py
13 issues
Line: 7
Column: 5
import uwebsocket
except ImportError:
print("SKIP")
raise SystemExit
# put raw data in the stream and do a websocket read
def ws_read(msg, sz):
ws = uwebsocket.websocket(uio.BytesIO(msg))
return ws.read(sz)
Reported by Pylint.
Line: 11
Column: 5
# put raw data in the stream and do a websocket read
def ws_read(msg, sz):
ws = uwebsocket.websocket(uio.BytesIO(msg))
return ws.read(sz)
# do a websocket write and then return the raw data from the stream
def ws_write(msg, sz):
Reported by Pylint.
Line: 17
Column: 5
# do a websocket write and then return the raw data from the stream
def ws_write(msg, sz):
s = uio.BytesIO()
ws = uwebsocket.websocket(s)
ws.write(msg)
s.seek(0)
return s.read(sz)
Reported by Pylint.
Line: 18
Column: 5
# do a websocket write and then return the raw data from the stream
def ws_write(msg, sz):
s = uio.BytesIO()
ws = uwebsocket.websocket(s)
ws.write(msg)
s.seek(0)
return s.read(sz)
Reported by Pylint.
Line: 1
Column: 1
try:
import uio
import uerrno
import uwebsocket
except ImportError:
print("SKIP")
raise SystemExit
# put raw data in the stream and do a websocket read
Reported by Pylint.
Line: 10
Column: 1
raise SystemExit
# put raw data in the stream and do a websocket read
def ws_read(msg, sz):
ws = uwebsocket.websocket(uio.BytesIO(msg))
return ws.read(sz)
# do a websocket write and then return the raw data from the stream
Reported by Pylint.
Line: 10
Column: 1
raise SystemExit
# put raw data in the stream and do a websocket read
def ws_read(msg, sz):
ws = uwebsocket.websocket(uio.BytesIO(msg))
return ws.read(sz)
# do a websocket write and then return the raw data from the stream
Reported by Pylint.
Line: 11
Column: 5
# put raw data in the stream and do a websocket read
def ws_read(msg, sz):
ws = uwebsocket.websocket(uio.BytesIO(msg))
return ws.read(sz)
# do a websocket write and then return the raw data from the stream
def ws_write(msg, sz):
Reported by Pylint.
Line: 16
Column: 1
# do a websocket write and then return the raw data from the stream
def ws_write(msg, sz):
s = uio.BytesIO()
ws = uwebsocket.websocket(s)
ws.write(msg)
s.seek(0)
return s.read(sz)
Reported by Pylint.
Line: 16
Column: 1
# do a websocket write and then return the raw data from the stream
def ws_write(msg, sz):
s = uio.BytesIO()
ws = uwebsocket.websocket(s)
ws.write(msg)
s.seek(0)
return s.read(sz)
Reported by Pylint.
ports/esp32/boards/UM_TINYS2/modules/tinys2.py
13 issues
Line: 10
Column: 1
# 2021-Apr-10 - v0.1 - Initial implementation
# Import required libraries
from micropython import const
from machine import Pin, SPI, ADC
import machine, time
# TinyS2 Hardware Pin Assignments
Reported by Pylint.
Line: 11
Column: 1
# Import required libraries
from micropython import const
from machine import Pin, SPI, ADC
import machine, time
# TinyS2 Hardware Pin Assignments
# Sense Pins
Reported by Pylint.
Line: 12
Column: 1
# Import required libraries
from micropython import const
from machine import Pin, SPI, ADC
import machine, time
# TinyS2 Hardware Pin Assignments
# Sense Pins
VBUS_SENSE = const(21)
Reported by Pylint.
Line: 11
Column: 1
# Import required libraries
from micropython import const
from machine import Pin, SPI, ADC
import machine, time
# TinyS2 Hardware Pin Assignments
# Sense Pins
Reported by Pylint.
Line: 12
Column: 1
# Import required libraries
from micropython import const
from machine import Pin, SPI, ADC
import machine, time
# TinyS2 Hardware Pin Assignments
# Sense Pins
VBUS_SENSE = const(21)
Reported by Pylint.
Line: 1
Column: 1
# TinyS2 MicroPython Helper Library
# 2021 Seon Rozenblum - Unexpected Maker
#
# Project home:
# https://tinys2.io
#
# 2021-Apr-10 - v0.1 - Initial implementation
# Import required libraries
Reported by Pylint.
Line: 12
Column: 1
# Import required libraries
from micropython import const
from machine import Pin, SPI, ADC
import machine, time
# TinyS2 Hardware Pin Assignments
# Sense Pins
VBUS_SENSE = const(21)
Reported by Pylint.
Line: 12
Column: 1
# Import required libraries
from micropython import const
from machine import Pin, SPI, ADC
import machine, time
# TinyS2 Hardware Pin Assignments
# Sense Pins
VBUS_SENSE = const(21)
Reported by Pylint.
Line: 41
Column: 1
# Helper functions
def set_pixel_power(state):
"""Enable or Disable power to the onboard NeoPixel to either show colour, or to reduce power for deep sleep."""
Pin(RGB_PWR, Pin.OUT).value(state)
def get_battery_voltage():
"""
Reported by Pylint.
Line: 47
Column: 1
def get_battery_voltage():
"""
Returns the current battery voltage. If no battery is connected, returns 4.2V which is the charge voltage
This is an approximation only, but useful to detect if the charge state of the battery is getting low.
"""
adc = ADC(Pin(VBAT_SENSE)) # Assign the ADC pin to read
measuredvbat = adc.read() # Read the value
measuredvbat /= 8192 # divide by 8192 as we are using the default ADC voltage range of 0-1V
Reported by Pylint.