The following issues were found
tests/import/import_override.py
10 issues
Line: 4
Column: 25
# test overriding __import__ combined with importing from the filesystem
def custom_import(name, globals, locals, fromlist, level):
print("import", name, fromlist, level)
class M:
var = 456
Reported by Pylint.
Line: 4
Column: 34
# test overriding __import__ combined with importing from the filesystem
def custom_import(name, globals, locals, fromlist, level):
print("import", name, fromlist, level)
class M:
var = 456
Reported by Pylint.
Line: 4
Column: 25
# test overriding __import__ combined with importing from the filesystem
def custom_import(name, globals, locals, fromlist, level):
print("import", name, fromlist, level)
class M:
var = 456
Reported by Pylint.
Line: 4
Column: 34
# test overriding __import__ combined with importing from the filesystem
def custom_import(name, globals, locals, fromlist, level):
print("import", name, fromlist, level)
class M:
var = 456
Reported by Pylint.
Line: 18
Column: 5
__import__("builtins").__import__ = custom_import
except AttributeError:
print("SKIP")
raise SystemExit
# import1a will be done via normal import which will import1b via our custom import
orig_import("import1a")
Reported by Pylint.
Line: 1
Column: 1
# test overriding __import__ combined with importing from the filesystem
def custom_import(name, globals, locals, fromlist, level):
print("import", name, fromlist, level)
class M:
var = 456
Reported by Pylint.
Line: 4
Column: 1
# test overriding __import__ combined with importing from the filesystem
def custom_import(name, globals, locals, fromlist, level):
print("import", name, fromlist, level)
class M:
var = 456
Reported by Pylint.
Line: 7
Column: 5
def custom_import(name, globals, locals, fromlist, level):
print("import", name, fromlist, level)
class M:
var = 456
return M
Reported by Pylint.
Line: 7
Column: 5
def custom_import(name, globals, locals, fromlist, level):
print("import", name, fromlist, level)
class M:
var = 456
return M
Reported by Pylint.
Line: 7
Column: 5
def custom_import(name, globals, locals, fromlist, level):
print("import", name, fromlist, level)
class M:
var = 456
return M
Reported by Pylint.
tests/micropython/heapalloc_iter.py
10 issues
Line: 6
Column: 5
frozenset
except NameError:
print("SKIP")
raise SystemExit
try:
import uarray as array
except ImportError:
try:
import array
Reported by Pylint.
Line: 14
Column: 9
import array
except ImportError:
print("SKIP")
raise SystemExit
try:
from micropython import heap_lock, heap_unlock
except (ImportError, AttributeError):
heap_lock = heap_unlock = lambda: 0
Reported by Pylint.
Line: 22
Column: 13
heap_lock = heap_unlock = lambda: 0
def do_iter(l):
heap_lock()
for i in l:
print(i)
heap_unlock()
Reported by Pylint.
Line: 1
Column: 1
# test that iterating doesn't use the heap
try:
frozenset
except NameError:
print("SKIP")
raise SystemExit
try:
import uarray as array
except ImportError:
Reported by Pylint.
Line: 22
Column: 1
heap_lock = heap_unlock = lambda: 0
def do_iter(l):
heap_lock()
for i in l:
print(i)
heap_unlock()
Reported by Pylint.
Line: 22
Column: 1
heap_lock = heap_unlock = lambda: 0
def do_iter(l):
heap_lock()
for i in l:
print(i)
heap_unlock()
Reported by Pylint.
Line: 29
Column: 1
heap_unlock()
def gen_func():
yield 1
yield 2
# pre-create collections to iterate over
Reported by Pylint.
Line: 55
Column: 8
heap_unlock()
# test unpacking with the heap locked
unp0 = unp1 = unp2 = None # preallocate slots for globals
heap_lock()
unp0, unp1, unp2 = t
print(unp0, unp1, unp2)
heap_unlock()
Reported by Pylint.
Line: 55
Column: 1
heap_unlock()
# test unpacking with the heap locked
unp0 = unp1 = unp2 = None # preallocate slots for globals
heap_lock()
unp0, unp1, unp2 = t
print(unp0, unp1, unp2)
heap_unlock()
Reported by Pylint.
Line: 55
Column: 15
heap_unlock()
# test unpacking with the heap locked
unp0 = unp1 = unp2 = None # preallocate slots for globals
heap_lock()
unp0, unp1, unp2 = t
print(unp0, unp1, unp2)
heap_unlock()
Reported by Pylint.
examples/conwaylife.py
10 issues
Line: 43
Column: 9
# loop for a certain number of frames, doing iterations of Conway's Game of Life
def conway_go(num_frames):
for i in range(num_frames):
conway_step() # do 1 iteration
lcd.show() # update the LCD
pyb.delay(50)
Reported by Pylint.
Line: 1
Column: 1
# import essential libraries
import pyb
lcd = pyb.LCD("x")
lcd.light(1)
# do 1 iteration of Conway's Game of Life
def conway_step():
for x in range(128): # loop over x coordinates
Reported by Pylint.
Line: 8
Column: 1
lcd.light(1)
# do 1 iteration of Conway's Game of Life
def conway_step():
for x in range(128): # loop over x coordinates
for y in range(32): # loop over y coordinates
# count number of neighbours
num_neighbours = (
lcd.get(x - 1, y - 1)
Reported by Pylint.
Line: 9
Column: 9
# do 1 iteration of Conway's Game of Life
def conway_step():
for x in range(128): # loop over x coordinates
for y in range(32): # loop over y coordinates
# count number of neighbours
num_neighbours = (
lcd.get(x - 1, y - 1)
+ lcd.get(x, y - 1)
Reported by Pylint.
Line: 10
Column: 13
# do 1 iteration of Conway's Game of Life
def conway_step():
for x in range(128): # loop over x coordinates
for y in range(32): # loop over y coordinates
# count number of neighbours
num_neighbours = (
lcd.get(x - 1, y - 1)
+ lcd.get(x, y - 1)
+ lcd.get(x + 1, y - 1)
Reported by Pylint.
Line: 27
Column: 1
self = lcd.get(x, y)
# apply the rules of life
if self and not (2 <= num_neighbours <= 3):
lcd.pixel(x, y, 0) # not enough, or too many neighbours: cell dies
elif not self and num_neighbours == 3:
lcd.pixel(x, y, 1) # exactly 3 neighbours around an empty cell: cell is born
Reported by Pylint.
Line: 34
Column: 1
# randomise the start
def conway_rand():
lcd.fill(0) # clear the LCD
for x in range(128): # loop over x coordinates
for y in range(32): # loop over y coordinates
lcd.pixel(x, y, pyb.rng() & 1) # set the pixel randomly
Reported by Pylint.
Line: 36
Column: 9
# randomise the start
def conway_rand():
lcd.fill(0) # clear the LCD
for x in range(128): # loop over x coordinates
for y in range(32): # loop over y coordinates
lcd.pixel(x, y, pyb.rng() & 1) # set the pixel randomly
# loop for a certain number of frames, doing iterations of Conway's Game of Life
Reported by Pylint.
Line: 37
Column: 13
def conway_rand():
lcd.fill(0) # clear the LCD
for x in range(128): # loop over x coordinates
for y in range(32): # loop over y coordinates
lcd.pixel(x, y, pyb.rng() & 1) # set the pixel randomly
# loop for a certain number of frames, doing iterations of Conway's Game of Life
def conway_go(num_frames):
Reported by Pylint.
Line: 42
Column: 1
# loop for a certain number of frames, doing iterations of Conway's Game of Life
def conway_go(num_frames):
for i in range(num_frames):
conway_step() # do 1 iteration
lcd.show() # update the LCD
pyb.delay(50)
Reported by Pylint.
tests/unix/ffi_callback.py
10 issues
Line: 5
Column: 5
import ffi
except ImportError:
print("SKIP")
raise SystemExit
def ffi_open(names):
err = None
for n in names:
Reported by Pylint.
Line: 1
Column: 1
try:
import ffi
except ImportError:
print("SKIP")
raise SystemExit
def ffi_open(names):
err = None
Reported by Pylint.
Line: 8
Column: 1
raise SystemExit
def ffi_open(names):
err = None
for n in names:
try:
mod = ffi.open(n)
return mod
Reported by Pylint.
Line: 10
Column: 9
def ffi_open(names):
err = None
for n in names:
try:
mod = ffi.open(n)
return mod
except OSError as e:
err = e
Reported by Pylint.
Line: 14
Column: 9
try:
mod = ffi.open(n)
return mod
except OSError as e:
err = e
raise err
libc = ffi_open(("libc.so", "libc.so.0", "libc.so.6", "libc.dylib"))
Reported by Pylint.
Line: 24
Column: 1
qsort = libc.func("v", "qsort", "piip")
def cmp(pa, pb):
a = ffi.as_bytearray(pa, 1)
b = ffi.as_bytearray(pb, 1)
# print("cmp:", a, b)
return a[0] - b[0]
Reported by Pylint.
Line: 24
Column: 1
qsort = libc.func("v", "qsort", "piip")
def cmp(pa, pb):
a = ffi.as_bytearray(pa, 1)
b = ffi.as_bytearray(pb, 1)
# print("cmp:", a, b)
return a[0] - b[0]
Reported by Pylint.
Line: 24
Column: 1
qsort = libc.func("v", "qsort", "piip")
def cmp(pa, pb):
a = ffi.as_bytearray(pa, 1)
b = ffi.as_bytearray(pb, 1)
# print("cmp:", a, b)
return a[0] - b[0]
Reported by Pylint.
Line: 25
Column: 5
def cmp(pa, pb):
a = ffi.as_bytearray(pa, 1)
b = ffi.as_bytearray(pb, 1)
# print("cmp:", a, b)
return a[0] - b[0]
Reported by Pylint.
Line: 26
Column: 5
def cmp(pa, pb):
a = ffi.as_bytearray(pa, 1)
b = ffi.as_bytearray(pb, 1)
# print("cmp:", a, b)
return a[0] - b[0]
cmp_c = ffi.callback("i", cmp, "pp")
Reported by Pylint.
tests/perf_bench/viper_call2b.py
10 issues
Line: 1
Column: 2
@micropython.viper
def f2b(x: int, y: int) -> int:
return x + y
@micropython.native
def call(r):
f = f2b
for _ in r:
Reported by Pylint.
Line: 6
Column: 2
return x + y
@micropython.native
def call(r):
f = f2b
for _ in r:
f(1, 2)
Reported by Pylint.
Line: 1
Column: 1
@micropython.viper
def f2b(x: int, y: int) -> int:
return x + y
@micropython.native
def call(r):
f = f2b
for _ in r:
Reported by Pylint.
Line: 2
Column: 1
@micropython.viper
def f2b(x: int, y: int) -> int:
return x + y
@micropython.native
def call(r):
f = f2b
for _ in r:
Reported by Pylint.
Line: 2
Column: 1
@micropython.viper
def f2b(x: int, y: int) -> int:
return x + y
@micropython.native
def call(r):
f = f2b
for _ in r:
Reported by Pylint.
Line: 2
Column: 1
@micropython.viper
def f2b(x: int, y: int) -> int:
return x + y
@micropython.native
def call(r):
f = f2b
for _ in r:
Reported by Pylint.
Line: 7
Column: 1
@micropython.native
def call(r):
f = f2b
for _ in r:
f(1, 2)
Reported by Pylint.
Line: 7
Column: 1
@micropython.native
def call(r):
f = f2b
for _ in r:
f(1, 2)
Reported by Pylint.
Line: 8
Column: 5
@micropython.native
def call(r):
f = f2b
for _ in r:
f(1, 2)
bm_params = {
Reported by Pylint.
Line: 21
Column: 1
}
def bm_setup(params):
return lambda: call(range(params[0])), lambda: (params[0] // 1000, None)
Reported by Pylint.
tests/basics/try2.py
10 issues
Line: 7
Column: 9
print("try 1")
try:
print("try 2")
foo()
except:
print("except 2")
bar()
except:
print("except 1")
Reported by Pylint.
Line: 10
Column: 5
foo()
except:
print("except 2")
bar()
except:
print("except 1")
try:
print("try 1")
Reported by Pylint.
Line: 18
Column: 9
print("try 1")
try:
print("try 2")
foo()
except TypeError:
print("except 2")
bar()
except NameError:
print("except 1")
Reported by Pylint.
Line: 45
Column: 9
def func2():
try:
print("try func2")
foo()
except TypeError:
print("except func2")
func1()
Reported by Pylint.
Line: 8
Column: 5
try:
print("try 2")
foo()
except:
print("except 2")
bar()
except:
print("except 1")
Reported by Pylint.
Line: 11
Column: 1
except:
print("except 2")
bar()
except:
print("except 1")
try:
print("try 1")
try:
Reported by Pylint.
Line: 31
Column: 8
raise Exception
except (RuntimeError, SyntaxError):
print('except 2')
except Exception:
print('except 1')
# Check that exceptions across function boundaries work as expected
def func1():
try:
Reported by Pylint.
Line: 1
Column: 1
# nested try's
try:
print("try 1")
try:
print("try 2")
foo()
except:
print("except 2")
Reported by Pylint.
Line: 35
Column: 1
print('except 1')
# Check that exceptions across function boundaries work as expected
def func1():
try:
print("try func1")
func2()
except NameError:
print("except func1")
Reported by Pylint.
Line: 42
Column: 1
except NameError:
print("except func1")
def func2():
try:
print("try func2")
foo()
except TypeError:
print("except func2")
Reported by Pylint.
examples/natmod/features2/test.py
10 issues
Line: 12
Column: 17
def test():
tests = [
isclose(add(0.1, 0.2), 0.3),
isclose(add_f(0.1, 0.2), 0.3),
]
ar = array.array("f", [1, 2, 3.5])
productf(ar)
Reported by Pylint.
Line: 13
Column: 17
def test():
tests = [
isclose(add(0.1, 0.2), 0.3),
isclose(add_f(0.1, 0.2), 0.3),
]
ar = array.array("f", [1, 2, 3.5])
productf(ar)
tests.append(isclose(ar[0], 7))
Reported by Pylint.
Line: 17
Column: 5
]
ar = array.array("f", [1, 2, 3.5])
productf(ar)
tests.append(isclose(ar[0], 7))
if "add_d" in globals():
tests.append(isclose(add_d(0.1, 0.2), 0.3))
Reported by Pylint.
Line: 21
Column: 30
tests.append(isclose(ar[0], 7))
if "add_d" in globals():
tests.append(isclose(add_d(0.1, 0.2), 0.3))
print(tests)
if not all(tests):
raise SystemExit(1)
Reported by Pylint.
Line: 1
Column: 1
# This Python code will be merged with the C code in main.c
import array
def isclose(a, b):
return abs(a - b) < 1e-3
Reported by Pylint.
Line: 6
Column: 1
import array
def isclose(a, b):
return abs(a - b) < 1e-3
def test():
tests = [
Reported by Pylint.
Line: 6
Column: 1
import array
def isclose(a, b):
return abs(a - b) < 1e-3
def test():
tests = [
Reported by Pylint.
Line: 6
Column: 1
import array
def isclose(a, b):
return abs(a - b) < 1e-3
def test():
tests = [
Reported by Pylint.
Line: 10
Column: 1
return abs(a - b) < 1e-3
def test():
tests = [
isclose(add(0.1, 0.2), 0.3),
isclose(add_f(0.1, 0.2), 0.3),
]
Reported by Pylint.
Line: 16
Column: 5
isclose(add_f(0.1, 0.2), 0.3),
]
ar = array.array("f", [1, 2, 3.5])
productf(ar)
tests.append(isclose(ar[0], 7))
if "add_d" in globals():
tests.append(isclose(add_d(0.1, 0.2), 0.3))
Reported by Pylint.
tests/basics/string_format_error.py
10 issues
Line: 62
Column: 5
print('ValueError')
try:
'{}{}'.format(1)
except IndexError:
print('IndexError')
try:
'{0:+s}'.format('1')
Reported by Pylint.
Line: 14
Column: 5
print('IndexError')
try:
'}'.format('zzzz')
except ValueError:
print('ValueError')
# end of format parsing conversion specifier
try:
Reported by Pylint.
Line: 20
Column: 5
# end of format parsing conversion specifier
try:
'{!'.format('a')
except ValueError:
print('ValueError')
# unknown conversion specifier
try:
Reported by Pylint.
Line: 31
Column: 5
print('ValueError')
try:
'{abc'.format('zzzz')
except ValueError:
print('ValueError')
# expected ':' after specifier
try:
Reported by Pylint.
Line: 37
Column: 5
# expected ':' after specifier
try:
'{!s :}'.format(2)
except ValueError:
print('ValueError')
try:
'{}{0}'.format(1, 2)
Reported by Pylint.
Line: 42
Column: 5
print('ValueError')
try:
'{}{0}'.format(1, 2)
except ValueError:
print('ValueError')
try:
'{1:}'.format(1)
Reported by Pylint.
Line: 52
Column: 5
print('IndexError')
try:
'{ 0 :*^10}'.format(12)
except KeyError:
print('KeyError')
try:
'{0}{}'.format(1)
Reported by Pylint.
Line: 57
Column: 5
print('KeyError')
try:
'{0}{}'.format(1)
except ValueError:
print('ValueError')
try:
'{}{}'.format(1)
Reported by Pylint.
Line: 1
Column: 1
# tests for errors in {} format string
try:
'{0:0}'.format('zzz')
except (ValueError):
print('ValueError')
try:
'{1:}'.format(1)
Reported by Pylint.
Line: 5
Column: 1
try:
'{0:0}'.format('zzz')
except (ValueError):
print('ValueError')
try:
'{1:}'.format(1)
except IndexError:
Reported by Pylint.
tests/basics/del_name.py
10 issues
Line: 17
Column: 5
print("NameError")
class C:
def f():
pass
Reported by Pylint.
Line: 12
Column: 1
print("NameError")
try:
del x
except: # NameError:
# FIXME uPy returns KeyError for this
print("NameError")
class C:
def f():
Reported by Pylint.
Line: 13
Column: 3
try:
del x
except: # NameError:
# FIXME uPy returns KeyError for this
print("NameError")
class C:
def f():
pass
Reported by Pylint.
Line: 1
Column: 1
# del name
x = 1
print(x)
del x
try:
print(x)
except NameError:
print("NameError")
Reported by Pylint.
Line: 3
Column: 1
# del name
x = 1
print(x)
del x
try:
print(x)
except NameError:
print("NameError")
Reported by Pylint.
Line: 16
Column: 1
# FIXME uPy returns KeyError for this
print("NameError")
class C:
def f():
pass
Reported by Pylint.
Line: 16
Column: 1
# FIXME uPy returns KeyError for this
print("NameError")
class C:
def f():
pass
Reported by Pylint.
Line: 16
Column: 1
# FIXME uPy returns KeyError for this
print("NameError")
class C:
def f():
pass
Reported by Pylint.
Line: 17
Column: 5
print("NameError")
class C:
def f():
pass
Reported by Pylint.
Line: 17
Column: 5
print("NameError")
class C:
def f():
pass
Reported by Pylint.
tests/basics/generator_name.py
10 issues
Line: 16
Column: 5
print(A().Fun.__name__)
except AttributeError:
print('SKIP')
raise SystemExit
Reported by Pylint.
Line: 1
Column: 1
# test __name__ on generator functions
def Fun():
yield
class A:
def Fun(self):
yield
Reported by Pylint.
Line: 3
Column: 1
# test __name__ on generator functions
def Fun():
yield
class A:
def Fun(self):
yield
Reported by Pylint.
Line: 3
Column: 1
# test __name__ on generator functions
def Fun():
yield
class A:
def Fun(self):
yield
Reported by Pylint.
Line: 6
Column: 1
def Fun():
yield
class A:
def Fun(self):
yield
try:
print(Fun.__name__)
Reported by Pylint.
Line: 6
Column: 1
def Fun():
yield
class A:
def Fun(self):
yield
try:
print(Fun.__name__)
Reported by Pylint.
Line: 6
Column: 1
def Fun():
yield
class A:
def Fun(self):
yield
try:
print(Fun.__name__)
Reported by Pylint.
Line: 7
Column: 5
yield
class A:
def Fun(self):
yield
try:
print(Fun.__name__)
print(A.Fun.__name__)
Reported by Pylint.
Line: 7
Column: 5
yield
class A:
def Fun(self):
yield
try:
print(Fun.__name__)
print(A.Fun.__name__)
Reported by Pylint.
Line: 7
Column: 5
yield
class A:
def Fun(self):
yield
try:
print(Fun.__name__)
print(A.Fun.__name__)
Reported by Pylint.