The following issues were found

tests/internal_bench/arrayop-4-bytearray_map.py
5 issues
Unused variable 'i'
Error

Line: 9 Column: 9

              

def test(num):
    for i in iter(range(num // 10000)):
        arr = bytearray(b"\0" * 1000)
        arr2 = bytearray(map(lambda x: x + 1, arr))


bench.run(test)

            

Reported by Pylint.

Unused variable 'arr2'
Error

Line: 11 Column: 9

              def test(num):
    for i in iter(range(num // 10000)):
        arr = bytearray(b"\0" * 1000)
        arr2 = bytearray(map(lambda x: x + 1, arr))


bench.run(test)

            

Reported by Pylint.

Module name "arrayop-4-bytearray_map" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              # Array operation
# Type: list, map() call. This method requires allocation of
# the same amount of memory as original array (to hold result
# array). On the other hand, input array stays intact.
import bench


def test(num):
    for i in iter(range(num // 10000)):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Array operation
# Type: list, map() call. This method requires allocation of
# the same amount of memory as original array (to hold result
# array). On the other hand, input array stays intact.
import bench


def test(num):
    for i in iter(range(num // 10000)):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              import bench


def test(num):
    for i in iter(range(num // 10000)):
        arr = bytearray(b"\0" * 1000)
        arr2 = bytearray(map(lambda x: x + 1, arr))



            

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.

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.

tests/internal_bench/arrayop-1-list_inplace.py
5 issues
Redefining name 'i' from outer scope (line 8)
Error

Line: 10 Column: 9

              def test(num):
    for i in iter(range(num // 10000)):
        arr = [0] * 1000
        for i in range(len(arr)):
            arr[i] += 1


bench.run(test)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Array operation
# Type: list, inplace operation using for. What's good about this
# method is that it doesn't require any extra memory allocation.
import bench


def test(num):
    for i in iter(range(num // 10000)):
        arr = [0] * 1000

            

Reported by Pylint.

Module name "arrayop-1-list_inplace" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              # Array operation
# Type: list, inplace operation using for. What's good about this
# method is that it doesn't require any extra memory allocation.
import bench


def test(num):
    for i in iter(range(num // 10000)):
        arr = [0] * 1000

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              import bench


def test(num):
    for i in iter(range(num // 10000)):
        arr = [0] * 1000
        for i in range(len(arr)):
            arr[i] += 1


            

Reported by Pylint.

Consider using enumerate instead of iterating with range and len
Error

Line: 10 Column: 9

              def test(num):
    for i in iter(range(num // 10000)):
        arr = [0] * 1000
        for i in range(len(arr)):
            arr[i] += 1


bench.run(test)

            

Reported by Pylint.

tests/basics/generator_throw_nested.py
5 issues
Catching too general exception Exception
Error

Line: 11 Column: 20

                          yield 2
            try:
                yield 3
            except Exception:
                yield 4
                print(0)
            yield 5
        except Exception:
            yield 6

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 15 Column: 16

                              yield 4
                print(0)
            yield 5
        except Exception:
            yield 6
            print(1)
        yield 7
    except Exception:
        yield 8

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 19 Column: 12

                          yield 6
            print(1)
        yield 7
    except Exception:
        yield 8
        print(2)
    yield 9

for i in range(1, 10):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Tests that the correct nested exception handler is used when
# throwing into a generator (previously failed on native emitter).

def gen():
    try:
        yield 1
        try:
            yield 2
            try:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              # Tests that the correct nested exception handler is used when
# throwing into a generator (previously failed on native emitter).

def gen():
    try:
        yield 1
        try:
            yield 2
            try:

            

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/basics/generator_exc.py
5 issues
Unreachable code
Error

Line: 18 Column: 5

              def gen2():
    yield 1
    raise ValueError
    yield 2
    yield 3

g = gen2()
print(next(g))
try:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Test proper handling of exceptions within generator across yield
def gen():
    try:
        yield 1
        raise ValueError
    except ValueError:
        print("Caught")
    yield 2


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 2 Column: 1

              # Test proper handling of exceptions within generator across yield
def gen():
    try:
        yield 1
        raise ValueError
    except ValueError:
        print("Caught")
    yield 2


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

              

# Test throwing exceptions out of generator
def gen2():
    yield 1
    raise ValueError
    yield 2
    yield 3


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 1

              

# Test throwing exception into generator
def gen3():
    yield 1
    try:
        yield 2
    except ValueError:
        print("ValueError received")

            

Reported by Pylint.

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

Line: 7 Column: 5

                  exec
except NameError:
    print("SKIP")
    raise SystemExit


def test_syntax(code):
    try:
        exec(code)

            

Reported by Pylint.

Use of exec
Error

Line: 12 Column: 9

              
def test_syntax(code):
    try:
        exec(code)
        print("no SyntaxError")
    except SyntaxError:
        print("SyntaxError")



            

Reported by Pylint.

Use of exec detected.
Security

Line: 12
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html

              
def test_syntax(code):
    try:
        exec(code)
        print("no SyntaxError")
    except SyntaxError:
        print("SyntaxError")



            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              # test syntax errors using async

try:
    exec
except NameError:
    print("SKIP")
    raise SystemExit



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

                  raise SystemExit


def test_syntax(code):
    try:
        exec(code)
        print("no SyntaxError")
    except SyntaxError:
        print("SyntaxError")

            

Reported by Pylint.

tests/basics/gen_yield_from_pending.py
5 issues
No exception type(s) specified
Error

Line: 17 Column: 5

              def main():
    try:
        yield from raise_task()
    except:
        print('main exception')

    yield from noop_task()

for z in main():

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Tests that the pending exception state is managed correctly
# (previously failed on native emitter).

def noop_task():
    print('noop task')
    yield 1

def raise_task():
    print('raise task')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              # Tests that the pending exception state is managed correctly
# (previously failed on native emitter).

def noop_task():
    print('noop task')
    yield 1

def raise_task():
    print('raise task')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

                  print('noop task')
    yield 1

def raise_task():
    print('raise task')
    yield 2
    print('raising')
    raise Exception


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 1

                  print('raising')
    raise Exception

def main():
    try:
        yield from raise_task()
    except:
        print('main exception')


            

Reported by Pylint.

ports/esp8266/makeimg.py
5 issues
Use of insecure MD2, MD4, MD5, or SHA1 hash function.
Security blacklist

Line: 14
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b303-md5

              
assert len(sys.argv) == 4

md5 = hashlib.md5()

with open(sys.argv[3], "wb") as fout:

    with open(sys.argv[1], "rb") as f:
        data_flash = f.read()

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              import sys
import struct
import hashlib

# This region at the start of flash contains a small header and then segments
# containing .text, .data and .rodata, and so must be large enough to hold all
# of this.  This data is loaded to the appropriate places in RAM by the ROM
# bootloader at boot.  After this in flash comes .irom0.text, which must begin
# on a flash erase-page boundary.

            

Reported by Pylint.

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

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

              # on a flash erase-page boundary.
SEGS_MAX_SIZE = 0x9000

assert len(sys.argv) == 4

md5 = hashlib.md5()

with open(sys.argv[3], "wb") as fout:


            

Reported by Bandit.

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

Line: 28 Column: 9

              
        # Print info about segments in this first part of flash
        num_segs = struct.unpack_from("<BBBBI", data_flash, 0)[1]
        offset = 8
        for seg_num in range(num_segs):
            seg_name = [".text", ".data", ".rodata"][seg_num]
            seg_offset, seg_size = struct.unpack_from("<II", data_flash, offset)
            print(" {:7}  {} at 0x{:x}".format(seg_name, seg_size, seg_offset))
            offset += 8 + seg_size

            

Reported by Pylint.

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

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

                      data_rom = f.read()

    pad = b"\xff" * (SEGS_MAX_SIZE - len(data_flash))
    assert len(pad) >= 4
    fout.write(pad[:-4])
    md5.update(pad[:-4])
    len_data = struct.pack("I", SEGS_MAX_SIZE + len(data_rom))
    fout.write(len_data)
    md5.update(len_data)

            

Reported by Bandit.