The following issues were found
tests/basics/builtin_property.py
33 issues
Line: 6
Column: 5
property
except:
print("SKIP")
raise SystemExit
# create a property object explicitly
property()
property(1, 2, 3)
Reported by Pylint.
Line: 1
Column: 1
# test builtin property
try:
property
except:
print("SKIP")
raise SystemExit
# create a property object explicitly
property()
Reported by Pylint.
Line: 19
Column: 1
p.deleter(3)
# basic use as a decorator
class A:
def __init__(self, x):
self._x = x
@property
def x(self):
Reported by Pylint.
Line: 19
Column: 1
p.deleter(3)
# basic use as a decorator
class A:
def __init__(self, x):
self._x = x
@property
def x(self):
Reported by Pylint.
Line: 19
Column: 1
p.deleter(3)
# basic use as a decorator
class A:
def __init__(self, x):
self._x = x
@property
def x(self):
Reported by Pylint.
Line: 24
Column: 5
self._x = x
@property
def x(self):
print("x get")
return self._x
a = A(1)
print(a.x)
Reported by Pylint.
Line: 24
Column: 5
self._x = x
@property
def x(self):
print("x get")
return self._x
a = A(1)
print(a.x)
Reported by Pylint.
Line: 32
Column: 5
print(a.x)
try:
a.x = 2
except AttributeError:
print("AttributeError")
# explicit use within a class
class B:
Reported by Pylint.
Line: 37
Column: 1
print("AttributeError")
# explicit use within a class
class B:
def __init__(self, x):
self._x = x
def xget(self):
print("x get")
Reported by Pylint.
Line: 37
Column: 1
print("AttributeError")
# explicit use within a class
class B:
def __init__(self, x):
self._x = x
def xget(self):
print("x get")
Reported by Pylint.
tests/unix/extra_coverage.py
33 issues
Line: 7
Column: 1
print("SKIP")
raise SystemExit
import uerrno
import uio
data = extra_coverage()
# test hashing of str/bytes that have an invalid hash
Reported by Pylint.
Line: 8
Column: 1
raise SystemExit
import uerrno
import uio
data = extra_coverage()
# test hashing of str/bytes that have an invalid hash
print(data[0], data[1])
Reported by Pylint.
Line: 10
Column: 8
import uerrno
import uio
data = extra_coverage()
# test hashing of str/bytes that have an invalid hash
print(data[0], data[1])
print(hash(data[0]))
print(hash(data[1]))
Reported by Pylint.
Line: 50
Column: 14
print(buf.write(bytearray(16)))
# function defined in C++ code
print("cpp", extra_cpp_coverage())
# test user C module
import cexample
print(cexample.add_ints(3, 2))
Reported by Pylint.
Line: 53
Column: 1
print("cpp", extra_cpp_coverage())
# test user C module
import cexample
print(cexample.add_ints(3, 2))
# test user C module mixed with C++ code
import cppexample
Reported by Pylint.
Line: 58
Column: 1
print(cexample.add_ints(3, 2))
# test user C module mixed with C++ code
import cppexample
print(cppexample.cppfunc(1, 2))
# test basic import of frozen scripts
import frzstr1
Reported by Pylint.
Line: 63
Column: 1
print(cppexample.cppfunc(1, 2))
# test basic import of frozen scripts
import frzstr1
print(frzstr1.__file__)
import frzmpy1
print(frzmpy1.__file__)
Reported by Pylint.
Line: 66
Column: 1
import frzstr1
print(frzstr1.__file__)
import frzmpy1
print(frzmpy1.__file__)
# test import of frozen packages with __init__.py
import frzstr_pkg1
Reported by Pylint.
Line: 71
Column: 1
print(frzmpy1.__file__)
# test import of frozen packages with __init__.py
import frzstr_pkg1
print(frzstr_pkg1.__file__, frzstr_pkg1.x)
import frzmpy_pkg1
print(frzmpy_pkg1.__file__, frzmpy_pkg1.x)
Reported by Pylint.
Line: 74
Column: 1
import frzstr_pkg1
print(frzstr_pkg1.__file__, frzstr_pkg1.x)
import frzmpy_pkg1
print(frzmpy_pkg1.__file__, frzmpy_pkg1.x)
# test import of frozen packages without __init__.py
from frzstr_pkg2.mod import Foo
Reported by Pylint.
tests/float/float2int_intbig.py
32 issues
Line: 6
Column: 1
try:
import ustruct as struct
import usys as sys
except:
import struct
import sys
maxsize_bits = 0
maxsize = sys.maxsize
Reported by Pylint.
Line: 52
Column: 3
testpass = False
print("power of 2 test: %s" % (testpass and "passed" or "failed"))
# TODO why does 10**12 fail this test for single precision float?
testpass = True
p10_rng = 9 if (ll_type == 0 and ~is_64bit) else 11
for i in range(0, p10_rng):
digcnt = len(str(int(10.0 ** i))) - 1
if i != digcnt:
Reported by Pylint.
Line: 65
Column: 9
def fp2int_test(num, name, should_fail):
try:
x = int(num)
passed = ~should_fail
except:
passed = should_fail
print("%s: %s" % (name, passed and "passed" or "failed"))
Reported by Pylint.
Line: 67
Column: 5
try:
x = int(num)
passed = ~should_fail
except:
passed = should_fail
print("%s: %s" % (name, passed and "passed" or "failed"))
if ll_type != 2:
Reported by Pylint.
Line: 1
Column: 1
# check cases converting float to int, relying only on single precision float
try:
import ustruct as struct
import usys as sys
except:
import struct
import sys
Reported by Pylint.
Line: 10
Column: 1
import struct
import sys
maxsize_bits = 0
maxsize = sys.maxsize
while maxsize:
maxsize >>= 1
maxsize_bits += 1
Reported by Pylint.
Line: 19
Column: 1
# work out configuration values
is_64bit = maxsize_bits > 32
# 0 = none, 1 = long long, 2 = mpz
ll_type = None
if is_64bit:
if maxsize_bits < 63:
ll_type = 0
else:
if maxsize_bits < 31:
Reported by Pylint.
Line: 22
Column: 9
ll_type = None
if is_64bit:
if maxsize_bits < 63:
ll_type = 0
else:
if maxsize_bits < 31:
ll_type = 0
if ll_type is None:
one = 1
Reported by Pylint.
Line: 25
Column: 9
ll_type = 0
else:
if maxsize_bits < 31:
ll_type = 0
if ll_type is None:
one = 1
if one << 65 < one << 62:
ll_type = 1
else:
Reported by Pylint.
Line: 27
Column: 5
if maxsize_bits < 31:
ll_type = 0
if ll_type is None:
one = 1
if one << 65 < one << 62:
ll_type = 1
else:
ll_type = 2
Reported by Pylint.
tests/float/float2int_fp30_intbig.py
32 issues
Line: 6
Column: 1
try:
import ustruct as struct
import usys as sys
except:
import struct
import sys
maxsize_bits = 0
maxsize = sys.maxsize
Reported by Pylint.
Line: 49
Column: 3
testpass = False
print("power of 2 test: %s" % (testpass and "passed" or "failed"))
# TODO why does 10**12 fail this test for single precision float?
testpass = True
p10_rng = 9
for i in range(0, p10_rng):
digcnt = len(str(int(10.0 ** i))) - 1
if i != digcnt:
Reported by Pylint.
Line: 62
Column: 9
def fp2int_test(num, name, should_fail):
try:
x = int(num)
passed = ~should_fail
except:
passed = should_fail
print("%s: %s" % (name, passed and "passed" or "failed"))
Reported by Pylint.
Line: 64
Column: 5
try:
x = int(num)
passed = ~should_fail
except:
passed = should_fail
print("%s: %s" % (name, passed and "passed" or "failed"))
if ll_type != 2:
Reported by Pylint.
Line: 1
Column: 1
# check cases converting float to int, relying only on single precision float
try:
import ustruct as struct
import usys as sys
except:
import struct
import sys
Reported by Pylint.
Line: 10
Column: 1
import struct
import sys
maxsize_bits = 0
maxsize = sys.maxsize
while maxsize:
maxsize >>= 1
maxsize_bits += 1
Reported by Pylint.
Line: 19
Column: 1
# work out configuration values
is_64bit = maxsize_bits > 32
# 0 = none, 1 = long long, 2 = mpz
ll_type = None
if is_64bit:
if maxsize_bits < 63:
ll_type = 0
else:
if maxsize_bits < 31:
Reported by Pylint.
Line: 22
Column: 9
ll_type = None
if is_64bit:
if maxsize_bits < 63:
ll_type = 0
else:
if maxsize_bits < 31:
ll_type = 0
if ll_type is None:
one = 1
Reported by Pylint.
Line: 25
Column: 9
ll_type = 0
else:
if maxsize_bits < 31:
ll_type = 0
if ll_type is None:
one = 1
if one << 65 < one << 62:
ll_type = 1
else:
Reported by Pylint.
Line: 27
Column: 5
if maxsize_bits < 31:
ll_type = 0
if ll_type is None:
one = 1
if one << 65 < one << 62:
ll_type = 1
else:
ll_type = 2
Reported by Pylint.
tests/extmod/vfs_lfs_mount.py
31 issues
Line: 61
Column: 5
# import
with open("/lfs/lfsmod.py", "w") as f:
f.write('print("hello from lfs")\n')
import lfsmod
# import package
uos.mkdir("/lfs/lfspkg")
with open("/lfs/lfspkg/__init__.py", "w") as f:
f.write('print("package")\n')
Reported by Pylint.
Line: 67
Column: 5
uos.mkdir("/lfs/lfspkg")
with open("/lfs/lfspkg/__init__.py", "w") as f:
f.write('print("package")\n')
import lfspkg
# chdir and import module from current directory (needs "" in sys.path)
uos.mkdir("/lfs/subdir")
uos.chdir("/lfs/subdir")
uos.rename("/lfs/lfsmod.py", "/lfs/subdir/lfsmod2.py")
Reported by Pylint.
Line: 73
Column: 5
uos.mkdir("/lfs/subdir")
uos.chdir("/lfs/subdir")
uos.rename("/lfs/lfsmod.py", "/lfs/subdir/lfsmod2.py")
import lfsmod2
# umount
uos.umount("/lfs")
# mount read-only
Reported by Pylint.
Line: 106
Column: 1
# initialise path
import usys
usys.path.clear()
usys.path.append("/lfs")
usys.path.append("")
Reported by Pylint.
Line: 6
Column: 5
try:
import uos
uos.VfsLfs1
uos.VfsLfs2
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 7
Column: 5
import uos
uos.VfsLfs1
uos.VfsLfs2
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 10
Column: 5
uos.VfsLfs2
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
class RAMBlockDevice:
ERASE_BLOCK_SIZE = 1024
Reported by Pylint.
Line: 29
Column: 25
for i in range(len(buf)):
self.data[addr + i] = buf[i]
def ioctl(self, op, arg):
if op == 4: # block count
return len(self.data) // self.ERASE_BLOCK_SIZE
if op == 5: # block size
return self.ERASE_BLOCK_SIZE
if op == 6: # erase block
Reported by Pylint.
Line: 46
Column: 12
# mount bdev unformatted
try:
uos.mount(bdev, "/lfs")
except Exception as er:
print(repr(er))
# mkfs
vfs_class.mkfs(bdev)
Reported by Pylint.
Line: 61
Column: 5
# import
with open("/lfs/lfsmod.py", "w") as f:
f.write('print("hello from lfs")\n')
import lfsmod
# import package
uos.mkdir("/lfs/lfspkg")
with open("/lfs/lfspkg/__init__.py", "w") as f:
f.write('print("package")\n')
Reported by Pylint.
py/makecompresseddata.py
31 issues
Line: 85
Column: 5
# For comparison only (the table is not emitted).
def huffman_compression(error_strings):
# https://github.com/tannewt/huffman
import huffman
all_strings = "".join(error_strings)
cb = huffman.codebook(collections.Counter(all_strings).items())
for line in error_strings:
Reported by Pylint.
Line: 104
Column: 3
result = line
error_strings[line] = result
# TODO: This would be the prefix lengths and the table ordering.
return "_" * (10 + len(cb))
# Replace common N-letter sequences with <0x80 | index>, where
# the common sequences are stored in a separate table.
Reported by Pylint.
Line: 1
Column: 1
from __future__ import print_function
import collections
import re
import sys
import gzip
import zlib
Reported by Pylint.
Line: 14
Column: 1
_COMPRESSED_MARKER = 0xFF
def check_non_ascii(msg):
for c in msg:
if ord(c) >= 0x80:
print(
'Unable to generate compressed data: message "{}" contains a non-ascii character "{}".'.format(
msg, c
Reported by Pylint.
Line: 15
Column: 9
def check_non_ascii(msg):
for c in msg:
if ord(c) >= 0x80:
print(
'Unable to generate compressed data: message "{}" contains a non-ascii character "{}".'.format(
msg, c
),
Reported by Pylint.
Line: 18
Column: 1
for c in msg:
if ord(c) >= 0x80:
print(
'Unable to generate compressed data: message "{}" contains a non-ascii character "{}".'.format(
msg, c
),
file=sys.stderr,
)
sys.exit(1)
Reported by Pylint.
Line: 28
Column: 1
# Replace <char><space> with <char | 0x80>.
# Trival scheme to demo/test.
def space_compression(error_strings):
for line in error_strings:
check_non_ascii(line)
result = ""
for i in range(len(line)):
if i > 0 and line[i] == " ":
Reported by Pylint.
Line: 28
Column: 1
# Replace <char><space> with <char | 0x80>.
# Trival scheme to demo/test.
def space_compression(error_strings):
for line in error_strings:
check_non_ascii(line)
result = ""
for i in range(len(line)):
if i > 0 and line[i] == " ":
Reported by Pylint.
Line: 32
Column: 9
for line in error_strings:
check_non_ascii(line)
result = ""
for i in range(len(line)):
if i > 0 and line[i] == " ":
result = result[:-1]
result += "\\{:03o}".format(ord(line[i - 1]))
else:
result += line[i]
Reported by Pylint.
Line: 44
Column: 1
# Replace common words with <0x80 | index>.
# Index is into a table of words stored as aaaaa<0x80|a>bbb<0x80|b>...
# Replaced words are assumed to have spaces either side to avoid having to store the spaces in the compressed strings.
def word_compression(error_strings):
topn = collections.Counter()
for line in error_strings.keys():
check_non_ascii(line)
Reported by Pylint.
drivers/display/ssd1306.py
30 issues
Line: 3
Column: 1
# MicroPython SSD1306 OLED driver, I2C and SPI interfaces
from micropython import const
import framebuf
# register definitions
SET_CONTRAST = const(0x81)
SET_ENTIRE_ON = const(0xA4)
Reported by Pylint.
Line: 4
Column: 1
# MicroPython SSD1306 OLED driver, I2C and SPI interfaces
from micropython import const
import framebuf
# register definitions
SET_CONTRAST = const(0x81)
SET_ENTIRE_ON = const(0xA4)
Reported by Pylint.
Line: 143
Column: 9
import time
self.res(1)
time.sleep_ms(1)
self.res(0)
time.sleep_ms(10)
self.res(1)
super().__init__(width, height, external_vcc)
Reported by Pylint.
Line: 145
Column: 9
self.res(1)
time.sleep_ms(1)
self.res(0)
time.sleep_ms(10)
self.res(1)
super().__init__(width, height, external_vcc)
def write_cmd(self, cmd):
self.spi.init(baudrate=self.rate, polarity=0, phase=0)
Reported by Pylint.
Line: 1
Column: 1
# MicroPython SSD1306 OLED driver, I2C and SPI interfaces
from micropython import const
import framebuf
# register definitions
SET_CONTRAST = const(0x81)
SET_ENTIRE_ON = const(0xA4)
Reported by Pylint.
Line: 29
Column: 1
# Subclassing FrameBuffer provides support for graphics primitives
# http://docs.micropython.org/en/latest/pyboard/library/framebuf.html
class SSD1306(framebuf.FrameBuffer):
def __init__(self, width, height, external_vcc):
self.width = width
self.height = height
self.external_vcc = external_vcc
self.pages = self.height // 8
Reported by Pylint.
Line: 39
Column: 5
super().__init__(self.buffer, self.width, self.height, framebuf.MONO_VLSB)
self.init_display()
def init_display(self):
for cmd in (
SET_DISP, # display off
# address setting
SET_MEM_ADDR,
0x00, # horizontal
Reported by Pylint.
Line: 78
Column: 5
self.fill(0)
self.show()
def poweroff(self):
self.write_cmd(SET_DISP)
def poweron(self):
self.write_cmd(SET_DISP | 0x01)
Reported by Pylint.
Line: 81
Column: 5
def poweroff(self):
self.write_cmd(SET_DISP)
def poweron(self):
self.write_cmd(SET_DISP | 0x01)
def contrast(self, contrast):
self.write_cmd(SET_CONTRAST)
self.write_cmd(contrast)
Reported by Pylint.
Line: 84
Column: 5
def poweron(self):
self.write_cmd(SET_DISP | 0x01)
def contrast(self, contrast):
self.write_cmd(SET_CONTRAST)
self.write_cmd(contrast)
def invert(self, invert):
self.write_cmd(SET_NORM_INV | (invert & 1))
Reported by Pylint.
tests/float/float2int_doubleprec_intbig.py
30 issues
Line: 6
Column: 1
try:
import ustruct as struct
import usys as sys
except:
import struct
import sys
maxsize_bits = 0
maxsize = sys.maxsize
Reported by Pylint.
Line: 65
Column: 9
def fp2int_test(num, name, should_fail):
try:
x = int(num)
passed = ~should_fail
except:
passed = should_fail
print("%s: %s" % (name, passed and "passed" or "failed"))
Reported by Pylint.
Line: 67
Column: 5
try:
x = int(num)
passed = ~should_fail
except:
passed = should_fail
print("%s: %s" % (name, passed and "passed" or "failed"))
if ll_type != 2:
Reported by Pylint.
Line: 1
Column: 1
# check cases converting float to int, requiring double precision float
try:
import ustruct as struct
import usys as sys
except:
import struct
import sys
Reported by Pylint.
Line: 10
Column: 1
import struct
import sys
maxsize_bits = 0
maxsize = sys.maxsize
while maxsize:
maxsize >>= 1
maxsize_bits += 1
Reported by Pylint.
Line: 19
Column: 1
# work out configuration values
is_64bit = maxsize_bits > 32
# 0 = none, 1 = long long, 2 = mpz
ll_type = None
if is_64bit:
if maxsize_bits < 63:
ll_type = 0
else:
if maxsize_bits < 31:
Reported by Pylint.
Line: 22
Column: 9
ll_type = None
if is_64bit:
if maxsize_bits < 63:
ll_type = 0
else:
if maxsize_bits < 31:
ll_type = 0
if ll_type is None:
one = 1
Reported by Pylint.
Line: 25
Column: 9
ll_type = 0
else:
if maxsize_bits < 31:
ll_type = 0
if ll_type is None:
one = 1
if one << 65 < one << 62:
ll_type = 1
else:
Reported by Pylint.
Line: 27
Column: 5
if maxsize_bits < 31:
ll_type = 0
if ll_type is None:
one = 1
if one << 65 < one << 62:
ll_type = 1
else:
ll_type = 2
Reported by Pylint.
Line: 29
Column: 9
if ll_type is None:
one = 1
if one << 65 < one << 62:
ll_type = 1
else:
ll_type = 2
# This case occurs with time.time() values
if ll_type != 0:
Reported by Pylint.
tests/basics/builtin_override.py
30 issues
Line: 31
Column: 1
return M
builtins.__import__ = custom_import
__import__('A', None, None, None, 0)
import a
import a.b
from a import a
from a.b import a, b
from .a import a
from ..a import a, b
Reported by Pylint.
Line: 32
Column: 1
builtins.__import__ = custom_import
__import__('A', None, None, None, 0)
import a
import a.b
from a import a
from a.b import a, b
from .a import a
from ..a import a, b
Reported by Pylint.
Line: 33
Column: 1
__import__('A', None, None, None, 0)
import a
import a.b
from a import a
from a.b import a, b
from .a import a
from ..a import a, b
Reported by Pylint.
Line: 34
Column: 1
import a
import a.b
from a import a
from a.b import a, b
from .a import a
from ..a import a, b
Reported by Pylint.
Line: 35
Column: 1
import a.b
from a import a
from a.b import a, b
from .a import a
from ..a import a, b
Reported by Pylint.
Line: 36
Column: 1
from a import a
from a.b import a, b
from .a import a
from ..a import a, b
Reported by Pylint.
Line: 10
Column: 5
builtins.abs = lambda x: x + 1
except AttributeError:
print("SKIP")
raise SystemExit
print(abs(1))
# __build_class__ is handled in a special way
orig_build_class = __build_class__
Reported by Pylint.
Line: 23
Column: 34
builtins.__build_class__ = orig_build_class
# __import__ is handled in a special way
def custom_import(name, globals, locals, fromlist, level):
print('import', name, fromlist, level)
class M:
a = 1
b = 2
return M
Reported by Pylint.
Line: 23
Column: 25
builtins.__build_class__ = orig_build_class
# __import__ is handled in a special way
def custom_import(name, globals, locals, fromlist, level):
print('import', name, fromlist, level)
class M:
a = 1
b = 2
return M
Reported by Pylint.
Line: 23
Column: 34
builtins.__build_class__ = orig_build_class
# __import__ is handled in a special way
def custom_import(name, globals, locals, fromlist, level):
print('import', name, fromlist, level)
class M:
a = 1
b = 2
return M
Reported by Pylint.
tests/basics/try_finally_break.py
30 issues
Line: 18
Column: 1
f()
# where the finally swallows an exception
def f():
lst = [1, 2, 3]
for x in lst:
print('a', x)
try:
raise Exception
Reported by Pylint.
Line: 31
Column: 1
f()
# basic nested finally with break in inner finally
def f():
for i in range(2):
print('iter', i)
try:
raise TypeError
finally:
Reported by Pylint.
Line: 45
Column: 1
print(f())
# similar to above but more nesting
def f():
for i in range(2):
try:
raise ValueError
finally:
print(1)
Reported by Pylint.
Line: 62
Column: 1
print(f())
# lots of nesting
def f():
for i in range(2):
try:
raise ValueError
finally:
print(1)
Reported by Pylint.
Line: 79
Column: 1
print(f())
# basic case combined with try-else
def f(arg):
for _ in range(2):
print(1)
try:
if arg == 1:
raise ValueError
Reported by Pylint.
Line: 11
Column: 13
pass
finally:
print(2)
break
print(3)
print(4)
print(5)
f()
Reported by Pylint.
Line: 12
Column: 13
finally:
print(2)
break
print(3)
print(4)
print(5)
f()
# where the finally swallows an exception
Reported by Pylint.
Line: 26
Column: 13
raise Exception
finally:
print(1)
break
print('b', x)
f()
# basic nested finally with break in inner finally
def f():
Reported by Pylint.
Line: 41
Column: 17
try:
raise ValueError
finally:
break
print(f())
# similar to above but more nesting
def f():
for i in range(2):
Reported by Pylint.
Line: 46
Column: 9
# similar to above but more nesting
def f():
for i in range(2):
try:
raise ValueError
finally:
print(1)
try:
Reported by Pylint.