The following issues were found

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

Line: 10 Column: 9

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

try:
    m = re.match(".", "a")
    m.span
except AttributeError:

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 14 Column: 5

              
try:
    m = re.match(".", "a")
    m.span
except AttributeError:
    print("SKIP")
    raise SystemExit



            

Reported by Pylint.

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

Line: 17 Column: 5

                  m.span
except AttributeError:
    print("SKIP")
    raise SystemExit


def print_spans(match):
    print("----")
    try:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test match.span(), and nested spans

try:
    import ure as re
except ImportError:
    try:
        import re
    except ImportError:
        print("SKIP")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

                  raise SystemExit


def print_spans(match):
    print("----")
    try:
        i = 0
        while True:
            print(match.span(i), match.start(i), match.end(i))

            

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.

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

Line: 10 Column: 5

                  sys.exc_info
except:
    print("SKIP")
    raise SystemExit


def f():
    print(sys.exc_info()[0:2])


            

Reported by Pylint.

No exception type(s) specified
Error

Line: 19 Column: 1

              
try:
    raise ValueError("value", 123)
except:
    print(sys.exc_info()[0:2])
    f()

# Outside except block, sys.exc_info() should be back to None's
f()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    import usys as sys
except ImportError:
    import sys

try:
    sys.exc_info
except:
    print("SKIP")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

                  raise SystemExit


def f():
    print(sys.exc_info()[0:2])


try:
    raise ValueError("value", 123)

            

Reported by Pylint.

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

Line: 13 Column: 1

                  raise SystemExit


def f():
    print(sys.exc_info()[0:2])


try:
    raise ValueError("value", 123)

            

Reported by Pylint.

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

Line: 7 Column: 5

                  import ure as re
except ImportError:
    print("SKIP")
    raise SystemExit


def test_re(r):
    try:
        re.compile(r)

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 13 Column: 5

              def test_re(r):
    try:
        re.compile(r)
    except:
        print("Error")


# too many chars in []
test_re("[" + "a" * 256 + "]")

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Test overflow in ure.compile output code.

try:
    import ure as re
except ImportError:
    print("SKIP")
    raise SystemExit



            

Reported by Pylint.

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

Line: 10 Column: 1

                  raise SystemExit


def test_re(r):
    try:
        re.compile(r)
    except:
        print("Error")


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

                  raise SystemExit


def test_re(r):
    try:
        re.compile(r)
    except:
        print("Error")


            

Reported by Pylint.

ports/nrf/examples/musictest.py
5 issues
Unable to import 'machine'
Error

Line: 8 Column: 1

              #  play("P3")
#

from machine import Pin
import music


def play(pin_str):
    p = Pin(pin_str, mode=Pin.OUT)

            

Reported by Pylint.

Unable to import 'music'
Error

Line: 9 Column: 1

              #

from machine import Pin
import music


def play(pin_str):
    p = Pin(pin_str, mode=Pin.OUT)
    music.play(music.PRELUDE, pin=p)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #
# Example usage where "P3" is the Buzzer pin.
#
#  from musictest import play
#  play("P3")
#

from machine import Pin
import music

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 1

              import music


def play(pin_str):
    p = Pin(pin_str, mode=Pin.OUT)
    music.play(music.PRELUDE, pin=p)

            

Reported by Pylint.

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

Line: 13 Column: 5

              

def play(pin_str):
    p = Pin(pin_str, mode=Pin.OUT)
    music.play(music.PRELUDE, pin=p)

            

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/basics/builtin_slice.py
5 issues
Missing module docstring
Error

Line: 1 Column: 1

              # test builtin slice

# print slice
class A:
    def __getitem__(self, idx):
        print(idx)
        return idx
s = A()[1:2:3]


            

Reported by Pylint.

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

Line: 4 Column: 1

              # test builtin slice

# print slice
class A:
    def __getitem__(self, idx):
        print(idx)
        return idx
s = A()[1:2:3]


            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 4 Column: 1

              # test builtin slice

# print slice
class A:
    def __getitem__(self, idx):
        print(idx)
        return idx
s = A()[1:2:3]


            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              # test builtin slice

# print slice
class A:
    def __getitem__(self, idx):
        print(idx)
        return idx
s = A()[1:2:3]


            

Reported by Pylint.

Using type() instead of isinstance() for a typecheck.
Error

Line: 11 Column: 7

              s = A()[1:2:3]

# check type
print(type(s) is slice)

            

Reported by Pylint.

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/extmod/ujson_dump_separators.py
5 issues
Unable to import 'uio'
Error

Line: 2 Column: 5

              try:
    from uio import StringIO
    import ujson as json
except:
    try:
        from io import StringIO
        import json
    except ImportError:
        print("SKIP")

            

Reported by Pylint.

Unable to import 'ujson'
Error

Line: 3 Column: 5

              try:
    from uio import StringIO
    import ujson as json
except:
    try:
        from io import StringIO
        import json
    except ImportError:
        print("SKIP")

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 4 Column: 1

              try:
    from uio import StringIO
    import ujson as json
except:
    try:
        from io import StringIO
        import json
    except ImportError:
        print("SKIP")

            

Reported by Pylint.

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

Line: 10 Column: 9

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

for sep in [
    None,
    (", ", ": "),
    (",", ": "),

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    from uio import StringIO
    import ujson as json
except:
    try:
        from io import StringIO
        import json
    except ImportError:
        print("SKIP")

            

Reported by Pylint.