The following issues were found

tests/basics/try_finally_continue.py
6 issues
Statement seems to have no effect
Error

Line: 11 Column: 25

                                  print(x, i)
                finally:
                    try:
                        1 / 0
                    finally:
                        return 42
            finally:
                print('continue')
                continue

            

Reported by Pylint.

return statement in finally block may swallow exception
Error

Line: 13 Column: 25

                                  try:
                        1 / 0
                    finally:
                        return 42
            finally:
                print('continue')
                continue
print(foo(4))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              def foo(x):
    for i in range(x):
        try:
            pass
        finally:
            try:
                try:
                    print(x, i)
                finally:

            

Reported by Pylint.

Argument name "x" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              def foo(x):
    for i in range(x):
        try:
            pass
        finally:
            try:
                try:
                    print(x, i)
                finally:

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 1 Column: 1

              def foo(x):
    for i in range(x):
        try:
            pass
        finally:
            try:
                try:
                    print(x, i)
                finally:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 1 Column: 1

              def foo(x):
    for i in range(x):
        try:
            pass
        finally:
            try:
                try:
                    print(x, i)
                finally:

            

Reported by Pylint.

tests/basics/try_continue.py
6 issues
Catching too general exception Exception
Error

Line: 10 Column: 16

                      try:
            if x == 2:
                raise Exception
        except Exception:
            continue
        print('b', x)
f()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test continue within exception handler

def f():
    lst = [1, 2, 3]
    for x in lst:
        print('a', x)
        try:
            if x == 2:
                raise Exception

            

Reported by Pylint.

Function name "f" doesn't conform to snake_case naming style
Error

Line: 3 Column: 1

              # test continue within exception handler

def f():
    lst = [1, 2, 3]
    for x in lst:
        print('a', x)
        try:
            if x == 2:
                raise Exception

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # test continue within exception handler

def f():
    lst = [1, 2, 3]
    for x in lst:
        print('a', x)
        try:
            if x == 2:
                raise Exception

            

Reported by Pylint.

Variable name "x" doesn't conform to snake_case naming style
Error

Line: 5 Column: 9

              
def f():
    lst = [1, 2, 3]
    for x in lst:
        print('a', x)
        try:
            if x == 2:
                raise Exception
        except Exception:

            

Reported by Pylint.

Try, Except, Continue detected.
Security

Line: 10
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b112_try_except_continue.html

                      try:
            if x == 2:
                raise Exception
        except Exception:
            continue
        print('b', x)
f()

            

Reported by Bandit.

tests/basics/sys_getsizeof.py
6 issues
Consider explicitly re-raising using the 'from' keyword
Error

Line: 11 Column: 5

                  sys.getsizeof
except AttributeError:
    print('SKIP')
    raise SystemExit

print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)

class A:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test sys.getsizeof() function

try:
    import usys as sys
except ImportError:
    import sys
try:
    sys.getsizeof
except AttributeError:

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 16 Column: 1

              print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)

class A:
    pass
print(sys.getsizeof(A()) > 0)

# Only test deque if we have it
try:

            

Reported by Pylint.

Class name "A" doesn't conform to PascalCase naming style
Error

Line: 16 Column: 1

              print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)

class A:
    pass
print(sys.getsizeof(A()) > 0)

# Only test deque if we have it
try:

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)

class A:
    pass
print(sys.getsizeof(A()) > 0)

# Only test deque if we have it
try:

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 23
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              # Only test deque if we have it
try:
    from ucollections import deque
    assert sys.getsizeof(deque((), 1)) > 0
except ImportError:
    pass

            

Reported by Bandit.

tests/extmod/uctypes_sizeof_od.py
6 issues
Consider explicitly re-raising using the 'from' keyword
Error

Line: 6 Column: 5

                  import uctypes
except ImportError:
    print("SKIP")
    raise SystemExit

desc = OrderedDict(
    {
        # arr is array at offset 0, of UINT8 elements, array size is 2
        "arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    from ucollections import OrderedDict
    import uctypes
except ImportError:
    print("SKIP")
    raise SystemExit

desc = OrderedDict(
    {

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 31
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              S = uctypes.struct(uctypes.addressof(data), desc, uctypes.LITTLE_ENDIAN)

print(uctypes.sizeof(S.arr))
assert uctypes.sizeof(S.arr) == 2

print(uctypes.sizeof(S.arr2))
assert uctypes.sizeof(S.arr2) == 2

print(uctypes.sizeof(S.arr3))

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 34
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              assert uctypes.sizeof(S.arr) == 2

print(uctypes.sizeof(S.arr2))
assert uctypes.sizeof(S.arr2) == 2

print(uctypes.sizeof(S.arr3))

try:
    print(uctypes.sizeof(S.arr3[0]))

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 44
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  print("TypeError")

print(uctypes.sizeof(S.arr4))
assert uctypes.sizeof(S.arr4) == 6

print(uctypes.sizeof(S.sub))
assert uctypes.sizeof(S.sub) == 1

# invalid descriptor

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 47
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              assert uctypes.sizeof(S.arr4) == 6

print(uctypes.sizeof(S.sub))
assert uctypes.sizeof(S.sub) == 1

# invalid descriptor
try:
    print(uctypes.sizeof([]))
except TypeError:

            

Reported by Bandit.

tests/extmod/uctypes_sizeof.py
6 issues
Consider explicitly re-raising using the 'from' keyword
Error

Line: 5 Column: 5

                  import uctypes
except ImportError:
    print("SKIP")
    raise SystemExit

desc = {
    # arr is array at offset 0, of UINT8 elements, array size is 2
    "arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),
    # arr2 is array at offset 0, size 2, of structures defined recursively

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    import uctypes
except ImportError:
    print("SKIP")
    raise SystemExit

desc = {
    # arr is array at offset 0, of UINT8 elements, array size is 2
    "arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 28
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              S = uctypes.struct(uctypes.addressof(data), desc, uctypes.LITTLE_ENDIAN)

print(uctypes.sizeof(S.arr))
assert uctypes.sizeof(S.arr) == 2

print(uctypes.sizeof(S.arr2))
assert uctypes.sizeof(S.arr2) == 2

print(uctypes.sizeof(S.arr3))

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 31
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              assert uctypes.sizeof(S.arr) == 2

print(uctypes.sizeof(S.arr2))
assert uctypes.sizeof(S.arr2) == 2

print(uctypes.sizeof(S.arr3))

try:
    print(uctypes.sizeof(S.arr3[0]))

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 41
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  print("TypeError")

print(uctypes.sizeof(S.arr4))
assert uctypes.sizeof(S.arr4) == 6

print(uctypes.sizeof(S.sub))
assert uctypes.sizeof(S.sub) == 1

# invalid descriptor

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 44
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              assert uctypes.sizeof(S.arr4) == 6

print(uctypes.sizeof(S.sub))
assert uctypes.sizeof(S.sub) == 1

# invalid descriptor
try:
    print(uctypes.sizeof([]))
except TypeError:

            

Reported by Bandit.

tests/basics/io_buffered_writer.py
5 issues
Unable to import 'uio'
Error

Line: 1 Column: 1

              import uio as io

try:
    io.BytesIO
    io.BufferedWriter
except AttributeError:
    print('SKIP')
    raise SystemExit


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 4 Column: 5

              import uio as io

try:
    io.BytesIO
    io.BufferedWriter
except AttributeError:
    print('SKIP')
    raise SystemExit


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 5 Column: 5

              
try:
    io.BytesIO
    io.BufferedWriter
except AttributeError:
    print('SKIP')
    raise SystemExit

bts = io.BytesIO()

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 8 Column: 5

                  io.BufferedWriter
except AttributeError:
    print('SKIP')
    raise SystemExit

bts = io.BytesIO()
buf = io.BufferedWriter(bts, 8)

buf.write(b"foobar")

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import uio as io

try:
    io.BytesIO
    io.BufferedWriter
except AttributeError:
    print('SKIP')
    raise SystemExit


            

Reported by Pylint.

tests/basics/int_big_zeroone.py
5 issues
Missing module docstring
Error

Line: 1 Column: 1

              # test [0,-0,1,-1] edge cases of bignum

long_zero = (2**64) >> 65
long_neg_zero = -long_zero
long_one = long_zero + 1
long_neg_one = -long_one

cases = [long_zero, long_neg_zero, long_one, long_neg_one]


            

Reported by Pylint.

Constant name "long_zero" doesn't conform to UPPER_CASE naming style
Error

Line: 3 Column: 1

              # test [0,-0,1,-1] edge cases of bignum

long_zero = (2**64) >> 65
long_neg_zero = -long_zero
long_one = long_zero + 1
long_neg_one = -long_one

cases = [long_zero, long_neg_zero, long_one, long_neg_one]


            

Reported by Pylint.

Constant name "long_neg_zero" doesn't conform to UPPER_CASE naming style
Error

Line: 4 Column: 1

              # test [0,-0,1,-1] edge cases of bignum

long_zero = (2**64) >> 65
long_neg_zero = -long_zero
long_one = long_zero + 1
long_neg_one = -long_one

cases = [long_zero, long_neg_zero, long_one, long_neg_one]


            

Reported by Pylint.

Constant name "long_one" doesn't conform to UPPER_CASE naming style
Error

Line: 5 Column: 1

              
long_zero = (2**64) >> 65
long_neg_zero = -long_zero
long_one = long_zero + 1
long_neg_one = -long_one

cases = [long_zero, long_neg_zero, long_one, long_neg_one]

print(cases)

            

Reported by Pylint.

Constant name "long_neg_one" doesn't conform to UPPER_CASE naming style
Error

Line: 6 Column: 1

              long_zero = (2**64) >> 65
long_neg_zero = -long_zero
long_one = long_zero + 1
long_neg_one = -long_one

cases = [long_zero, long_neg_zero, long_one, long_neg_one]

print(cases)
print([-c for c in cases])

            

Reported by Pylint.

tests/extmod/uctypes_array_assign_native_le_intbig.py
5 issues
Unable to import 'usys'
Error

Line: 1 Column: 1

              import usys

try:
    import uctypes
except ImportError:
    print("SKIP")
    raise SystemExit

if usys.byteorder != "little":

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 7 Column: 5

                  import uctypes
except ImportError:
    print("SKIP")
    raise SystemExit

if usys.byteorder != "little":
    print("SKIP")
    raise SystemExit


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import usys

try:
    import uctypes
except ImportError:
    print("SKIP")
    raise SystemExit

if usys.byteorder != "little":

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 37
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              # assign int64
S.arr11[0] = 0x11223344
print(hex(S.arr11[0]))
assert hex(S.arr11[0]) == "0x11223344"

# assign uint64
S.arr12[0] = 0x11223344
print(hex(S.arr12[0]))
assert hex(S.arr12[0]) == "0x11223344"

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 42
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              # assign uint64
S.arr12[0] = 0x11223344
print(hex(S.arr12[0]))
assert hex(S.arr12[0]) == "0x11223344"

            

Reported by Bandit.

tests/micropython/viper_binop_comp_imm.py
5 issues
Undefined variable 'micropython'
Error

Line: 2 Column: 2

              # comparisons with immediate boundary values
@micropython.viper
def f(a: int):
    print(a == -1, a == -255, a == -256, a == -257)


f(-1)
f(-255)
f(-256)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # comparisons with immediate boundary values
@micropython.viper
def f(a: int):
    print(a == -1, a == -255, a == -256, a == -257)


f(-1)
f(-255)
f(-256)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # comparisons with immediate boundary values
@micropython.viper
def f(a: int):
    print(a == -1, a == -255, a == -256, a == -257)


f(-1)
f(-255)
f(-256)

            

Reported by Pylint.

Argument name "a" doesn't conform to snake_case naming style
Error

Line: 3 Column: 1

              # comparisons with immediate boundary values
@micropython.viper
def f(a: int):
    print(a == -1, a == -255, a == -256, a == -257)


f(-1)
f(-255)
f(-256)

            

Reported by Pylint.

Function name "f" doesn't conform to snake_case naming style
Error

Line: 3 Column: 1

              # comparisons with immediate boundary values
@micropython.viper
def f(a: int):
    print(a == -1, a == -255, a == -256, a == -257)


f(-1)
f(-255)
f(-256)

            

Reported by Pylint.

ports/mimxrt/boards/TEENSY40/format.py
5 issues
Unable to import 'mimxrt'
Error

Line: 5 Column: 1

              # Re-create the file system

import os
import mimxrt

bdev = mimxrt.Flash()

os.VfsLfs2.mkfs(bdev, progsize=256)
vfs = os.VfsLfs2(bdev, progsize=256)

            

Reported by Pylint.

Module 'os' has no 'VfsLfs2' member
Error

Line: 9 Column: 1

              
bdev = mimxrt.Flash()

os.VfsLfs2.mkfs(bdev, progsize=256)
vfs = os.VfsLfs2(bdev, progsize=256)
os.mount(vfs, "/")

            

Reported by Pylint.

Module 'os' has no 'VfsLfs2' member
Error

Line: 10 Column: 7

              bdev = mimxrt.Flash()

os.VfsLfs2.mkfs(bdev, progsize=256)
vfs = os.VfsLfs2(bdev, progsize=256)
os.mount(vfs, "/")

            

Reported by Pylint.

Module 'os' has no 'mount' member
Error

Line: 11 Column: 1

              
os.VfsLfs2.mkfs(bdev, progsize=256)
vfs = os.VfsLfs2(bdev, progsize=256)
os.mount(vfs, "/")

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # format.py
# Re-create the file system

import os
import mimxrt

bdev = mimxrt.Flash()

os.VfsLfs2.mkfs(bdev, progsize=256)

            

Reported by Pylint.