The following issues were found

tests/basics/async_with_return.py
12 issues
Missing module docstring
Error

Line: 1 Column: 1

              # test async with, escaped by a return

class AContext:
    async def __aenter__(self):
        print('enter')
        return 1
    async def __aexit__(self, exc_type, exc, tb):
        print('exit', exc_type, exc)


            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              # test async with, escaped by a return

class AContext:
    async def __aenter__(self):
        print('enter')
        return 1
    async def __aexit__(self, exc_type, exc, tb):
        print('exit', exc_type, exc)


            

Reported by Pylint.

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

Line: 7 Column: 5

                  async def __aenter__(self):
        print('enter')
        return 1
    async def __aexit__(self, exc_type, exc, tb):
        print('exit', exc_type, exc)

async def f1():
    async with AContext():
        print('body')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

                  async def __aexit__(self, exc_type, exc, tb):
        print('exit', exc_type, exc)

async def f1():
    async with AContext():
        print('body')
        return

o = f1()

            

Reported by Pylint.

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

Line: 10 Column: 1

                  async def __aexit__(self, exc_type, exc, tb):
        print('exit', exc_type, exc)

async def f1():
    async with AContext():
        print('body')
        return

o = f1()

            

Reported by Pylint.

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

Line: 15 Column: 1

                      print('body')
        return

o = f1()
try:
    o.send(None)
except StopIteration:
    print('finished')


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 1

              except StopIteration:
    print('finished')

async def f2():
    try:
        async with AContext():
            print('body')
            return
    finally:

            

Reported by Pylint.

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

Line: 21 Column: 1

              except StopIteration:
    print('finished')

async def f2():
    try:
        async with AContext():
            print('body')
            return
    finally:

            

Reported by Pylint.

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

Line: 29 Column: 1

                  finally:
        print('finally')

o = f2()
try:
    o.send(None)
except StopIteration:
    print('finished')


            

Reported by Pylint.

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

Line: 35 Column: 1

              except StopIteration:
    print('finished')

async def f3():
    try:
        try:
            async with AContext():
                print('body')
                return

            

Reported by Pylint.

tests/basics/async_with_break.py
12 issues
Unreachable code
Error

Line: 15 Column: 13

                      async with AContext():
            print('body')
            break
            print('no 1')
        print('no 2')

o = f1()
try:
    print(o.send(None))

            

Reported by Pylint.

Unreachable code
Error

Line: 30 Column: 17

                          async with AContext():
                print('body')
                break
                print('no 1')
        finally:
            print('finally')
        print('no 2')

o = f2()

            

Reported by Pylint.

Unreachable code
Error

Line: 48 Column: 21

                              async with AContext():
                    print('body')
                    break
                    print('no 1')
            finally:
                print('finally inner')
        finally:
            print('finally outer')
        print('no 2')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test async with, escaped by a break

class AContext:
    async def __aenter__(self):
        print('enter')
        return 1
    async def __aexit__(self, exc_type, exc, tb):
        print('exit', exc_type, exc)


            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              # test async with, escaped by a break

class AContext:
    async def __aenter__(self):
        print('enter')
        return 1
    async def __aexit__(self, exc_type, exc, tb):
        print('exit', exc_type, exc)


            

Reported by Pylint.

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

Line: 7 Column: 5

                  async def __aenter__(self):
        print('enter')
        return 1
    async def __aexit__(self, exc_type, exc, tb):
        print('exit', exc_type, exc)

async def f1():
    while 1:
        async with AContext():

            

Reported by Pylint.

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

Line: 10 Column: 1

                  async def __aexit__(self, exc_type, exc, tb):
        print('exit', exc_type, exc)

async def f1():
    while 1:
        async with AContext():
            print('body')
            break
            print('no 1')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

                  async def __aexit__(self, exc_type, exc, tb):
        print('exit', exc_type, exc)

async def f1():
    while 1:
        async with AContext():
            print('body')
            break
            print('no 1')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 1

              except StopIteration:
    print('finished')

async def f2():
    while 1:
        try:
            async with AContext():
                print('body')
                break

            

Reported by Pylint.

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

Line: 24 Column: 1

              except StopIteration:
    print('finished')

async def f2():
    while 1:
        try:
            async with AContext():
                print('body')
                break

            

Reported by Pylint.

tests/inlineasm/asmconst.py
12 issues
Undefined variable 'micropython'
Error

Line: 4 Column: 2

              # test constants in assembler


@micropython.asm_thumb
def c1():
    movwt(r0, 0xFFFFFFFF)
    movwt(r1, 0xF0000000)
    sub(r0, r0, r1)


            

Reported by Pylint.

Undefined variable 'r0'
Error

Line: 6 Column: 11

              
@micropython.asm_thumb
def c1():
    movwt(r0, 0xFFFFFFFF)
    movwt(r1, 0xF0000000)
    sub(r0, r0, r1)


print(hex(c1()))

            

Reported by Pylint.

Undefined variable 'movwt'
Error

Line: 6 Column: 5

              
@micropython.asm_thumb
def c1():
    movwt(r0, 0xFFFFFFFF)
    movwt(r1, 0xF0000000)
    sub(r0, r0, r1)


print(hex(c1()))

            

Reported by Pylint.

Undefined variable 'r1'
Error

Line: 7 Column: 11

              @micropython.asm_thumb
def c1():
    movwt(r0, 0xFFFFFFFF)
    movwt(r1, 0xF0000000)
    sub(r0, r0, r1)


print(hex(c1()))

            

Reported by Pylint.

Undefined variable 'movwt'
Error

Line: 7 Column: 5

              @micropython.asm_thumb
def c1():
    movwt(r0, 0xFFFFFFFF)
    movwt(r1, 0xF0000000)
    sub(r0, r0, r1)


print(hex(c1()))

            

Reported by Pylint.

Undefined variable 'r1'
Error

Line: 8 Column: 17

              def c1():
    movwt(r0, 0xFFFFFFFF)
    movwt(r1, 0xF0000000)
    sub(r0, r0, r1)


print(hex(c1()))

            

Reported by Pylint.

Undefined variable 'sub'
Error

Line: 8 Column: 5

              def c1():
    movwt(r0, 0xFFFFFFFF)
    movwt(r1, 0xF0000000)
    sub(r0, r0, r1)


print(hex(c1()))

            

Reported by Pylint.

Undefined variable 'r0'
Error

Line: 8 Column: 9

              def c1():
    movwt(r0, 0xFFFFFFFF)
    movwt(r1, 0xF0000000)
    sub(r0, r0, r1)


print(hex(c1()))

            

Reported by Pylint.

Undefined variable 'r0'
Error

Line: 8 Column: 13

              def c1():
    movwt(r0, 0xFFFFFFFF)
    movwt(r1, 0xF0000000)
    sub(r0, r0, r1)


print(hex(c1()))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test constants in assembler


@micropython.asm_thumb
def c1():
    movwt(r0, 0xFFFFFFFF)
    movwt(r1, 0xF0000000)
    sub(r0, r0, r1)


            

Reported by Pylint.

tests/multi_net/tcp_accept_recv.py
12 issues
Undefined variable 'multitest'
Error

Line: 10 Column: 5

              
# Server
def instance0():
    multitest.globals(IP=multitest.get_network_ip())
    s = socket.socket()
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(socket.getaddrinfo("0.0.0.0", PORT)[0][-1])
    s.listen(1)
    multitest.next()

            

Reported by Pylint.

Undefined variable 'multitest'
Error

Line: 10 Column: 26

              
# Server
def instance0():
    multitest.globals(IP=multitest.get_network_ip())
    s = socket.socket()
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(socket.getaddrinfo("0.0.0.0", PORT)[0][-1])
    s.listen(1)
    multitest.next()

            

Reported by Pylint.

Undefined variable 'multitest'
Error

Line: 15 Column: 5

                  s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(socket.getaddrinfo("0.0.0.0", PORT)[0][-1])
    s.listen(1)
    multitest.next()
    s.accept()
    try:
        print("recv", s.recv(10))  # should raise Errno 107 ENOTCONN
    except OSError as er:
        print(er.errno)

            

Reported by Pylint.

Undefined variable 'multitest'
Error

Line: 26 Column: 5

              
# Client
def instance1():
    multitest.next()
    s = socket.socket()
    s.connect(socket.getaddrinfo(IP, PORT)[0][-1])
    s.send(b"GET / HTTP/1.0\r\n\r\n")
    s.close()

            

Reported by Pylint.

Undefined variable 'IP'
Error

Line: 28 Column: 34

              def instance1():
    multitest.next()
    s = socket.socket()
    s.connect(socket.getaddrinfo(IP, PORT)[0][-1])
    s.send(b"GET / HTTP/1.0\r\n\r\n")
    s.close()

            

Reported by Pylint.

Possible binding to all interfaces.
Security

Line: 13
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b104_hardcoded_bind_all_interfaces.html

                  multitest.globals(IP=multitest.get_network_ip())
    s = socket.socket()
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(socket.getaddrinfo("0.0.0.0", PORT)[0][-1])
    s.listen(1)
    multitest.next()
    s.accept()
    try:
        print("recv", s.recv(10))  # should raise Errno 107 ENOTCONN

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              # Test recv on socket that just accepted a connection

import socket

PORT = 8000


# Server
def instance0():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              

# Server
def instance0():
    multitest.globals(IP=multitest.get_network_ip())
    s = socket.socket()
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(socket.getaddrinfo("0.0.0.0", PORT)[0][-1])
    s.listen(1)

            

Reported by Pylint.

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

Line: 11 Column: 5

              # Server
def instance0():
    multitest.globals(IP=multitest.get_network_ip())
    s = socket.socket()
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(socket.getaddrinfo("0.0.0.0", PORT)[0][-1])
    s.listen(1)
    multitest.next()
    s.accept()

            

Reported by Pylint.

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

Line: 19 Column: 5

                  s.accept()
    try:
        print("recv", s.recv(10))  # should raise Errno 107 ENOTCONN
    except OSError as er:
        print(er.errno)
    s.close()


# Client

            

Reported by Pylint.

ports/esp32/makeimg.py
12 issues
Unable to import 'gen_esp32part'
Error

Line: 7 Column: 1

              
sys.path.append(os.getenv("IDF_PATH") + "/components/partition_table")

import gen_esp32part

OFFSET_BOOTLOADER_DEFAULT = 0x1000
OFFSET_PARTITIONS_DEFAULT = 0x8000



            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Combine bootloader, partition table and application into a final binary.

import os, sys

sys.path.append(os.getenv("IDF_PATH") + "/components/partition_table")

import gen_esp32part

OFFSET_BOOTLOADER_DEFAULT = 0x1000

            

Reported by Pylint.

Multiple imports on one line (os, sys)
Error

Line: 3 Column: 1

              # Combine bootloader, partition table and application into a final binary.

import os, sys

sys.path.append(os.getenv("IDF_PATH") + "/components/partition_table")

import gen_esp32part

OFFSET_BOOTLOADER_DEFAULT = 0x1000

            

Reported by Pylint.

Import "import gen_esp32part" should be placed at the top of the module
Error

Line: 7 Column: 1

              
sys.path.append(os.getenv("IDF_PATH") + "/components/partition_table")

import gen_esp32part

OFFSET_BOOTLOADER_DEFAULT = 0x1000
OFFSET_PARTITIONS_DEFAULT = 0x8000



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              OFFSET_PARTITIONS_DEFAULT = 0x8000


def load_sdkconfig_hex_value(filename, value, default):
    value = "CONFIG_" + value + "="
    with open(filename, "r") as f:
        for line in f:
            if line.startswith(value):
                return int(line.split("=", 1)[1], 16)

            

Reported by Pylint.

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

Line: 15 Column: 33

              
def load_sdkconfig_hex_value(filename, value, default):
    value = "CONFIG_" + value + "="
    with open(filename, "r") as f:
        for line in f:
            if line.startswith(value):
                return int(line.split("=", 1)[1], 16)
    return default


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 1

                  return default


def load_partition_table(filename):
    with open(filename, "rb") as f:
        return gen_esp32part.PartitionTable.from_binary(f.read())


# Extract command-line arguments.

            

Reported by Pylint.

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

Line: 23 Column: 34

              

def load_partition_table(filename):
    with open(filename, "rb") as f:
        return gen_esp32part.PartitionTable.from_binary(f.read())


# Extract command-line arguments.
arg_sdkconfig = sys.argv[1]

            

Reported by Pylint.

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

Line: 46 Column: 1

              partition_table = load_partition_table(arg_partitions_bin)

max_size_bootloader = offset_partitions - offset_bootloader
max_size_partitions = 0
offset_application = 0
max_size_application = 0

# Inspect the partition table to find offsets and maximum sizes.
for part in partition_table:

            

Reported by Pylint.

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

Line: 47 Column: 1

              
max_size_bootloader = offset_partitions - offset_bootloader
max_size_partitions = 0
offset_application = 0
max_size_application = 0

# Inspect the partition table to find offsets and maximum sizes.
for part in partition_table:
    if part.name == "nvs":

            

Reported by Pylint.

examples/network/http_server_ssl.py
12 issues
Unable to import 'ubinascii'
Error

Line: 1 Column: 1

              import ubinascii as binascii

try:
    import usocket as socket
except:
    import socket
import ussl as ssl



            

Reported by Pylint.

Unable to import 'ussl'
Error

Line: 7 Column: 1

                  import usocket as socket
except:
    import socket
import ussl as ssl


# This self-signed key/cert pair is randomly generated and to be used for
# testing/demonstration only.  You should always generate your own key/cert.
key = binascii.unhexlify(

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 5 Column: 1

              
try:
    import usocket as socket
except:
    import socket
import ussl as ssl


# This self-signed key/cert pair is randomly generated and to be used for

            

Reported by Pylint.

Possible binding to all interfaces.
Security

Line: 52
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b104_hardcoded_bind_all_interfaces.html

                  s = socket.socket()

    # Binding to all interfaces - server will be accessible to other hosts!
    ai = socket.getaddrinfo("0.0.0.0", 8443)
    print("Bind address info:", ai)
    addr = ai[0][-1]

    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(addr)

            

Reported by Bandit.

Catching too general exception Exception
Error

Line: 89 Column: 20

                                  print(h)
                if req:
                    client_s.write(CONTENT % counter)
            except Exception as e:
                print("Exception serving request:", e)
        else:
            print(client_s.recv(4096))
            client_s.send(CONTENT % counter)
        client_s.close()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import ubinascii as binascii

try:
    import usocket as socket
except:
    import socket
import ussl as ssl



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 48 Column: 1

              """


def main(use_stream=True):
    s = socket.socket()

    # Binding to all interfaces - server will be accessible to other hosts!
    ai = socket.getaddrinfo("0.0.0.0", 8443)
    print("Bind address info:", ai)

            

Reported by Pylint.

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

Line: 49 Column: 5

              

def main(use_stream=True):
    s = socket.socket()

    # Binding to all interfaces - server will be accessible to other hosts!
    ai = socket.getaddrinfo("0.0.0.0", 8443)
    print("Bind address info:", ai)
    addr = ai[0][-1]

            

Reported by Pylint.

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

Line: 52 Column: 5

                  s = socket.socket()

    # Binding to all interfaces - server will be accessible to other hosts!
    ai = socket.getaddrinfo("0.0.0.0", 8443)
    print("Bind address info:", ai)
    addr = ai[0][-1]

    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(addr)

            

Reported by Pylint.

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

Line: 83 Column: 21

                              req = client_s.readline()
                print(req)
                while True:
                    h = client_s.readline()
                    if h == b"" or h == b"\r\n":
                        break
                    print(h)
                if req:
                    client_s.write(CONTENT % counter)

            

Reported by Pylint.

tests/perf_bench/benchrun.py
12 issues
Undefined variable 'bm_params'
Error

Line: 13 Column: 18

                  # Pick sensible parameters given N, M
    cur_nm = (0, 0)
    param = None
    for nm, p in bm_params.items():
        if 10 * nm[0] <= 12 * N and nm[1] <= M and nm > cur_nm:
            cur_nm = nm
            param = p
    if param is None:
        print(-1, -1, "no matching params")

            

Reported by Pylint.

Undefined variable 'bm_setup'
Error

Line: 22 Column: 19

                      return

    # Run and time benchmark
    run, result = bm_setup(param)
    t0 = ticks_us()
    run()
    t1 = ticks_us()
    norm, out = result()
    print(ticks_diff(t1, t0), norm, out)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 1 Column: 1

              def bm_run(N, M):
    try:
        from utime import ticks_us, ticks_diff
    except ImportError:
        import time

        ticks_us = lambda: int(time.perf_counter() * 1000000)
        ticks_diff = lambda a, b: a - b


            

Reported by Pylint.

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

Line: 1 Column: 1

              def bm_run(N, M):
    try:
        from utime import ticks_us, ticks_diff
    except ImportError:
        import time

        ticks_us = lambda: int(time.perf_counter() * 1000000)
        ticks_diff = lambda a, b: a - b


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              def bm_run(N, M):
    try:
        from utime import ticks_us, ticks_diff
    except ImportError:
        import time

        ticks_us = lambda: int(time.perf_counter() * 1000000)
        ticks_diff = lambda a, b: a - b


            

Reported by Pylint.

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

Line: 1 Column: 1

              def bm_run(N, M):
    try:
        from utime import ticks_us, ticks_diff
    except ImportError:
        import time

        ticks_us = lambda: int(time.perf_counter() * 1000000)
        ticks_diff = lambda a, b: a - b


            

Reported by Pylint.

Import outside toplevel (utime.ticks_us, utime.ticks_diff)
Error

Line: 3 Column: 9

              def bm_run(N, M):
    try:
        from utime import ticks_us, ticks_diff
    except ImportError:
        import time

        ticks_us = lambda: int(time.perf_counter() * 1000000)
        ticks_diff = lambda a, b: a - b


            

Reported by Pylint.

Import outside toplevel (time)
Error

Line: 5 Column: 9

                  try:
        from utime import ticks_us, ticks_diff
    except ImportError:
        import time

        ticks_us = lambda: int(time.perf_counter() * 1000000)
        ticks_diff = lambda a, b: a - b

    # Pick sensible parameters given N, M

            

Reported by Pylint.

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

Line: 13 Column: 9

                  # Pick sensible parameters given N, M
    cur_nm = (0, 0)
    param = None
    for nm, p in bm_params.items():
        if 10 * nm[0] <= 12 * N and nm[1] <= M and nm > cur_nm:
            cur_nm = nm
            param = p
    if param is None:
        print(-1, -1, "no matching params")

            

Reported by Pylint.

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

Line: 13 Column: 13

                  # Pick sensible parameters given N, M
    cur_nm = (0, 0)
    param = None
    for nm, p in bm_params.items():
        if 10 * nm[0] <= 12 * N and nm[1] <= M and nm > cur_nm:
            cur_nm = nm
            param = p
    if param is None:
        print(-1, -1, "no matching params")

            

Reported by Pylint.

tests/basics/getattr.py
12 issues
class already defined line 3
Error

Line: 14 Column: 1

              print(a.a, a.b)

# test that any exception raised in __getattr__ propagates out
class A:
    def __getattr__(self, attr):
        if attr == "value":
            raise ValueError(123)
        else:
            raise AttributeError(456)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test __getattr__

class A:
    def __init__(self, d):
        self.d = d

    def __getattr__(self, attr):
        return self.d[attr]


            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              # test __getattr__

class A:
    def __init__(self, d):
        self.d = d

    def __getattr__(self, attr):
        return self.d[attr]


            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 3 Column: 1

              # test __getattr__

class A:
    def __init__(self, d):
        self.d = d

    def __getattr__(self, attr):
        return self.d[attr]


            

Reported by Pylint.

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

Line: 3 Column: 1

              # test __getattr__

class A:
    def __init__(self, d):
        self.d = d

    def __getattr__(self, attr):
        return self.d[attr]


            

Reported by Pylint.

Attribute name "d" doesn't conform to snake_case naming style
Error

Line: 5 Column: 9

              
class A:
    def __init__(self, d):
        self.d = d

    def __getattr__(self, attr):
        return self.d[attr]

a = A({'a':1, 'b':2})

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

              print(a.a, a.b)

# test that any exception raised in __getattr__ propagates out
class A:
    def __getattr__(self, attr):
        if attr == "value":
            raise ValueError(123)
        else:
            raise AttributeError(456)

            

Reported by Pylint.

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

Line: 14 Column: 1

              print(a.a, a.b)

# test that any exception raised in __getattr__ propagates out
class A:
    def __getattr__(self, attr):
        if attr == "value":
            raise ValueError(123)
        else:
            raise AttributeError(456)

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 14 Column: 1

              print(a.a, a.b)

# test that any exception raised in __getattr__ propagates out
class A:
    def __getattr__(self, attr):
        if attr == "value":
            raise ValueError(123)
        else:
            raise AttributeError(456)

            

Reported by Pylint.

Unnecessary "else" after "raise"
Error

Line: 16 Column: 9

              # test that any exception raised in __getattr__ propagates out
class A:
    def __getattr__(self, attr):
        if attr == "value":
            raise ValueError(123)
        else:
            raise AttributeError(456)
a = A()
try:

            

Reported by Pylint.

lib/littlefs/lfs2_util.h
12 issues
The address of local variable 'a' is accessed at non-zero index.
Error

Line: 171 CWE codes: 758

                  return __builtin_bswap32(a);
#else
    return (((uint8_t*)&a)[0] <<  0) |
           (((uint8_t*)&a)[1] <<  8) |
           (((uint8_t*)&a)[2] << 16) |
           (((uint8_t*)&a)[3] << 24);
#endif
}


            

Reported by Cppcheck.

The address of local variable 'a' is accessed at non-zero index.
Error

Line: 171 CWE codes: 758

                  return __builtin_bswap32(a);
#else
    return (((uint8_t*)&a)[0] <<  0) |
           (((uint8_t*)&a)[1] <<  8) |
           (((uint8_t*)&a)[2] << 16) |
           (((uint8_t*)&a)[3] << 24);
#endif
}


            

Reported by Cppcheck.

The address of local variable 'a' is accessed at non-zero index.
Error

Line: 172 CWE codes: 758

              #else
    return (((uint8_t*)&a)[0] <<  0) |
           (((uint8_t*)&a)[1] <<  8) |
           (((uint8_t*)&a)[2] << 16) |
           (((uint8_t*)&a)[3] << 24);
#endif
}

static inline uint32_t lfs2_tole32(uint32_t a) {

            

Reported by Cppcheck.

The address of local variable 'a' is accessed at non-zero index.
Error

Line: 172 CWE codes: 758

              #else
    return (((uint8_t*)&a)[0] <<  0) |
           (((uint8_t*)&a)[1] <<  8) |
           (((uint8_t*)&a)[2] << 16) |
           (((uint8_t*)&a)[3] << 24);
#endif
}

static inline uint32_t lfs2_tole32(uint32_t a) {

            

Reported by Cppcheck.

The address of local variable 'a' is accessed at non-zero index.
Error

Line: 173 CWE codes: 758

                  return (((uint8_t*)&a)[0] <<  0) |
           (((uint8_t*)&a)[1] <<  8) |
           (((uint8_t*)&a)[2] << 16) |
           (((uint8_t*)&a)[3] << 24);
#endif
}

static inline uint32_t lfs2_tole32(uint32_t a) {
    return lfs2_fromle32(a);

            

Reported by Cppcheck.

The address of local variable 'a' is accessed at non-zero index.
Error

Line: 173 CWE codes: 758

                  return (((uint8_t*)&a)[0] <<  0) |
           (((uint8_t*)&a)[1] <<  8) |
           (((uint8_t*)&a)[2] << 16) |
           (((uint8_t*)&a)[3] << 24);
#endif
}

static inline uint32_t lfs2_tole32(uint32_t a) {
    return lfs2_fromle32(a);

            

Reported by Cppcheck.

The address of local variable 'a' is accessed at non-zero index.
Error

Line: 195 CWE codes: 758

                  return a;
#else
    return (((uint8_t*)&a)[0] << 24) |
           (((uint8_t*)&a)[1] << 16) |
           (((uint8_t*)&a)[2] <<  8) |
           (((uint8_t*)&a)[3] <<  0);
#endif
}


            

Reported by Cppcheck.

The address of local variable 'a' is accessed at non-zero index.
Error

Line: 195 CWE codes: 758

                  return a;
#else
    return (((uint8_t*)&a)[0] << 24) |
           (((uint8_t*)&a)[1] << 16) |
           (((uint8_t*)&a)[2] <<  8) |
           (((uint8_t*)&a)[3] <<  0);
#endif
}


            

Reported by Cppcheck.

The address of local variable 'a' is accessed at non-zero index.
Error

Line: 196 CWE codes: 758

              #else
    return (((uint8_t*)&a)[0] << 24) |
           (((uint8_t*)&a)[1] << 16) |
           (((uint8_t*)&a)[2] <<  8) |
           (((uint8_t*)&a)[3] <<  0);
#endif
}

static inline uint32_t lfs2_tobe32(uint32_t a) {

            

Reported by Cppcheck.

The address of local variable 'a' is accessed at non-zero index.
Error

Line: 196 CWE codes: 758

              #else
    return (((uint8_t*)&a)[0] << 24) |
           (((uint8_t*)&a)[1] << 16) |
           (((uint8_t*)&a)[2] <<  8) |
           (((uint8_t*)&a)[3] <<  0);
#endif
}

static inline uint32_t lfs2_tobe32(uint32_t a) {

            

Reported by Cppcheck.

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

Line: 8 Column: 9

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

try:
    random.randint
except AttributeError:
    print("SKIP")

            

Reported by Pylint.

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

Line: 14 Column: 5

                  random.randint
except AttributeError:
    print("SKIP")
    raise SystemExit

print("randrange")
for i in range(50):
    assert 0 <= random.randrange(4) < 4
    assert 2 <= random.randrange(2, 6) < 6

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    import urandom as random
except ImportError:
    try:
        import random
    except ImportError:
        print("SKIP")
        raise SystemExit


            

Reported by Pylint.

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

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

              
print("randrange")
for i in range(50):
    assert 0 <= random.randrange(4) < 4
    assert 2 <= random.randrange(2, 6) < 6
    assert -2 <= random.randrange(-2, 2) < 2
    assert random.randrange(1, 9, 2) in (1, 3, 5, 7)
    assert random.randrange(2, 1, -1) in (1, 2)


            

Reported by Bandit.

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

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

              print("randrange")
for i in range(50):
    assert 0 <= random.randrange(4) < 4
    assert 2 <= random.randrange(2, 6) < 6
    assert -2 <= random.randrange(-2, 2) < 2
    assert random.randrange(1, 9, 2) in (1, 3, 5, 7)
    assert random.randrange(2, 1, -1) in (1, 2)

# empty range

            

Reported by Bandit.

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

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

              for i in range(50):
    assert 0 <= random.randrange(4) < 4
    assert 2 <= random.randrange(2, 6) < 6
    assert -2 <= random.randrange(-2, 2) < 2
    assert random.randrange(1, 9, 2) in (1, 3, 5, 7)
    assert random.randrange(2, 1, -1) in (1, 2)

# empty range
try:

            

Reported by Bandit.

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

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

                  assert 0 <= random.randrange(4) < 4
    assert 2 <= random.randrange(2, 6) < 6
    assert -2 <= random.randrange(-2, 2) < 2
    assert random.randrange(1, 9, 2) in (1, 3, 5, 7)
    assert random.randrange(2, 1, -1) in (1, 2)

# empty range
try:
    random.randrange(0)

            

Reported by Bandit.

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

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

                  assert 2 <= random.randrange(2, 6) < 6
    assert -2 <= random.randrange(-2, 2) < 2
    assert random.randrange(1, 9, 2) in (1, 3, 5, 7)
    assert random.randrange(2, 1, -1) in (1, 2)

# empty range
try:
    random.randrange(0)
except ValueError:

            

Reported by Bandit.

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

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

              
print("randint")
for i in range(50):
    assert 0 <= random.randint(0, 4) <= 4
    assert 2 <= random.randint(2, 6) <= 6
    assert -2 <= random.randint(-2, 2) <= 2

# empty range
try:

            

Reported by Bandit.

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

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

              print("randint")
for i in range(50):
    assert 0 <= random.randint(0, 4) <= 4
    assert 2 <= random.randint(2, 6) <= 6
    assert -2 <= random.randint(-2, 2) <= 2

# empty range
try:
    random.randint(2, 1)

            

Reported by Bandit.