The following issues were found

tests/float/cmath_fun.py
27 issues
Unused import asin from wildcard import
Error

Line: 4 Column: 5

              # test the functions imported from cmath

try:
    from cmath import *
except ImportError:
    print("SKIP")
    raise SystemExit

# make sure these constants exist in cmath

            

Reported by Pylint.

Unused import sinh from wildcard import
Error

Line: 4 Column: 5

              # test the functions imported from cmath

try:
    from cmath import *
except ImportError:
    print("SKIP")
    raise SystemExit

# make sure these constants exist in cmath

            

Reported by Pylint.

Unused import acos from wildcard import
Error

Line: 4 Column: 5

              # test the functions imported from cmath

try:
    from cmath import *
except ImportError:
    print("SKIP")
    raise SystemExit

# make sure these constants exist in cmath

            

Reported by Pylint.

Wildcard import cmath
Error

Line: 4 Column: 5

              # test the functions imported from cmath

try:
    from cmath import *
except ImportError:
    print("SKIP")
    raise SystemExit

# make sure these constants exist in cmath

            

Reported by Pylint.

Unused import tan from wildcard import
Error

Line: 4 Column: 5

              # test the functions imported from cmath

try:
    from cmath import *
except ImportError:
    print("SKIP")
    raise SystemExit

# make sure these constants exist in cmath

            

Reported by Pylint.

Unused import tanh from wildcard import
Error

Line: 4 Column: 5

              # test the functions imported from cmath

try:
    from cmath import *
except ImportError:
    print("SKIP")
    raise SystemExit

# make sure these constants exist in cmath

            

Reported by Pylint.

Unused import tau from wildcard import
Error

Line: 4 Column: 5

              # test the functions imported from cmath

try:
    from cmath import *
except ImportError:
    print("SKIP")
    raise SystemExit

# make sure these constants exist in cmath

            

Reported by Pylint.

Unused import acosh from wildcard import
Error

Line: 4 Column: 5

              # test the functions imported from cmath

try:
    from cmath import *
except ImportError:
    print("SKIP")
    raise SystemExit

# make sure these constants exist in cmath

            

Reported by Pylint.

Unused import asinh from wildcard import
Error

Line: 4 Column: 5

              # test the functions imported from cmath

try:
    from cmath import *
except ImportError:
    print("SKIP")
    raise SystemExit

# make sure these constants exist in cmath

            

Reported by Pylint.

Unused import atan from wildcard import
Error

Line: 4 Column: 5

              # test the functions imported from cmath

try:
    from cmath import *
except ImportError:
    print("SKIP")
    raise SystemExit

# make sure these constants exist in cmath

            

Reported by Pylint.

tests/esp32/resolve_on_connect.py
27 issues
Reimport 'sys' (imported line 2)
Error

Line: 9 Column: 5

                  raise SystemExit

try:
    import usocket as socket, sys
except:
    import socket, sys


def test_bind_resolves_0_0_0_0():

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 10 Column: 1

              
try:
    import usocket as socket, sys
except:
    import socket, sys


def test_bind_resolves_0_0_0_0():
    s = socket.socket()

            

Reported by Pylint.

Reimport 'sys' (imported line 2)
Error

Line: 11 Column: 5

              try:
    import usocket as socket, sys
except:
    import socket, sys


def test_bind_resolves_0_0_0_0():
    s = socket.socket()
    try:

            

Reported by Pylint.

Possible binding to all interfaces.
Security

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

              def test_bind_resolves_0_0_0_0():
    s = socket.socket()
    try:
        s.bind(("0.0.0.0", 31245))
        print("bind actually bound")
        s.close()
    except Exception as e:
        print("bind raised", e)


            

Reported by Bandit.

Catching too general exception Exception
Error

Line: 20 Column: 12

                      s.bind(("0.0.0.0", 31245))
        print("bind actually bound")
        s.close()
    except Exception as e:
        print("bind raised", e)


def test_bind_resolves_localhost():
    s = socket.socket()

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 30 Column: 12

                      s.bind(("localhost", 31245))
        print("bind actually bound")
        s.close()
    except Exception as e:
        print("bind raised", e)


def test_connect_resolves():
    s = socket.socket()

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 40 Column: 12

                      s.connect(("micropython.org", 80))
        print("connect actually connected")
        s.close()
    except Exception as e:
        print("connect raised", e)


def test_connect_non_existent():
    s = socket.socket()

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 52 Column: 12

                      s.close()
    except OSError as e:
        print("connect raised OSError")
    except Exception as e:
        print("connect raised", e)


test_funs = [n for n in dir() if n.startswith("test_")]
for f in sorted(test_funs):

            

Reported by Pylint.

Use of possibly insecure function - consider using safer ast.literal_eval.
Security blacklist

Line: 59
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval

              test_funs = [n for n in dir() if n.startswith("test_")]
for f in sorted(test_funs):
    print("--", f, end=": ")
    eval(f + "()")

            

Reported by Bandit.

Use of eval
Error

Line: 59 Column: 5

              test_funs = [n for n in dir() if n.startswith("test_")]
for f in sorted(test_funs):
    print("--", f, end=": ")
    eval(f + "()")

            

Reported by Pylint.

tools/upip_utarfile.py
27 issues
Unable to import 'uctypes'
Error

Line: 1 Column: 1

              import uctypes

# http://www.gnu.org/software/tar/manual/html_node/Standard.html
TAR_HEADER = {
    "name": (uctypes.ARRAY | 0, uctypes.UINT8 | 100),
    "size": (uctypes.ARRAY | 124, uctypes.UINT8 | 11),
}

DIRTYPE = "dir"

            

Reported by Pylint.

Attribute 'name' defined outside __init__
Error

Line: 79 Column: 9

                          return None

        d = TarInfo()
        d.name = str(h.name, "utf-8").rstrip("\0")
        d.size = int(bytes(h.size), 8)
        d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"]
        self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512))
        return d


            

Reported by Pylint.

Attribute 'size' defined outside __init__
Error

Line: 80 Column: 9

              
        d = TarInfo()
        d.name = str(h.name, "utf-8").rstrip("\0")
        d.size = int(bytes(h.size), 8)
        d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"]
        self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512))
        return d

    def __iter__(self):

            

Reported by Pylint.

Attribute 'type' defined outside __init__
Error

Line: 81 Column: 9

                      d = TarInfo()
        d.name = str(h.name, "utf-8").rstrip("\0")
        d.size = int(bytes(h.size), 8)
        d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"]
        self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512))
        return d

    def __iter__(self):
        return self

            

Reported by Pylint.

Attribute 'subf' defined outside __init__
Error

Line: 82 Column: 21

                      d.name = str(h.name, "utf-8").rstrip("\0")
        d.size = int(bytes(h.size), 8)
        d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"]
        self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512))
        return d

    def __iter__(self):
        return self


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import uctypes

# http://www.gnu.org/software/tar/manual/html_node/Standard.html
TAR_HEADER = {
    "name": (uctypes.ARRAY | 0, uctypes.UINT8 | 100),
    "size": (uctypes.ARRAY | 124, uctypes.UINT8 | 11),
}

DIRTYPE = "dir"

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              REGTYPE = "file"


def roundup(val, align):
    return (val + align - 1) & ~(align - 1)


class FileSection:
    def __init__(self, f, content_len, aligned_len):

            

Reported by Pylint.

Missing class docstring
Error

Line: 17 Column: 1

                  return (val + align - 1) & ~(align - 1)


class FileSection:
    def __init__(self, f, content_len, aligned_len):
        self.f = f
        self.content_len = content_len
        self.align = aligned_len - content_len


            

Reported by Pylint.

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

Line: 19 Column: 9

              
class FileSection:
    def __init__(self, f, content_len, aligned_len):
        self.f = f
        self.content_len = content_len
        self.align = aligned_len - content_len

    def read(self, sz=65536):
        if self.content_len == 0:

            

Reported by Pylint.

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

Line: 23 Column: 5

                      self.content_len = content_len
        self.align = aligned_len - content_len

    def read(self, sz=65536):
        if self.content_len == 0:
            return b""
        if sz > self.content_len:
            sz = self.content_len
        data = self.f.read(sz)

            

Reported by Pylint.

tests/basics/fun_kwonlydef.py
27 issues
Keyword argument before variable positional arguments list in the definition of f5 function
Error

Line: 32 Column: 1

              f4(f=6, e=55, d=4, c=33, b=2, a=11)

# positional with default, then keyword only
def f5(a, b=4, *c, d=8):
    print(a, b, c, d)
f5(1)
f5(1, d=9)
f5(1, b=44, d=9)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test function args, keyword only with default value

# a single arg with a default
def f1(*, a=1):
    print(a)
f1()
f1(a=2)

# 1 arg default, 1 not

            

Reported by Pylint.

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

Line: 4 Column: 1

              # test function args, keyword only with default value

# a single arg with a default
def f1(*, a=1):
    print(a)
f1()
f1(a=2)

# 1 arg default, 1 not

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              # test function args, keyword only with default value

# a single arg with a default
def f1(*, a=1):
    print(a)
f1()
f1(a=2)

# 1 arg default, 1 not

            

Reported by Pylint.

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

Line: 4 Column: 11

              # test function args, keyword only with default value

# a single arg with a default
def f1(*, a=1):
    print(a)
f1()
f1(a=2)

# 1 arg default, 1 not

            

Reported by Pylint.

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

Line: 10 Column: 16

              f1(a=2)

# 1 arg default, 1 not
def f2(*, a=1, b):
    print(a, b)
f2(b=2)
f2(a=2, b=3)

# 1 positional, 1 arg default, 1 not

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              f1(a=2)

# 1 arg default, 1 not
def f2(*, a=1, b):
    print(a, b)
f2(b=2)
f2(a=2, b=3)

# 1 positional, 1 arg default, 1 not

            

Reported by Pylint.

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

Line: 10 Column: 11

              f1(a=2)

# 1 arg default, 1 not
def f2(*, a=1, b):
    print(a, b)
f2(b=2)
f2(a=2, b=3)

# 1 positional, 1 arg default, 1 not

            

Reported by Pylint.

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

Line: 10 Column: 1

              f1(a=2)

# 1 arg default, 1 not
def f2(*, a=1, b):
    print(a, b)
f2(b=2)
f2(a=2, b=3)

# 1 positional, 1 arg default, 1 not

            

Reported by Pylint.

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

Line: 16 Column: 19

              f2(a=2, b=3)

# 1 positional, 1 arg default, 1 not
def f3(a, *, b=2, c):
    print(a, b, c)
f3(1, c=3)
f3(1, b=3, c=4)
f3(1, **{'c':3})
f3(1, **{'b':'3', 'c':4})

            

Reported by Pylint.

tests/pyb/can.py
27 issues
Unable to import 'micropython'
Error

Line: 8 Column: 1

                  raise SystemExit

from array import array
import micropython
import pyb

# test we can correctly create by id (2 handled in can2.py test)
for bus in (-1, 0, 1, 3):
    try:

            

Reported by Pylint.

Unable to import 'pyb'
Error

Line: 9 Column: 1

              
from array import array
import micropython
import pyb

# test we can correctly create by id (2 handled in can2.py test)
for bus in (-1, 0, 1, 3):
    try:
        CAN(bus, CAN.LOOPBACK)

            

Reported by Pylint.

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

Line: 5 Column: 5

                  from pyb import CAN
except ImportError:
    print("SKIP")
    raise SystemExit

from array import array
import micropython
import pyb


            

Reported by Pylint.

Unused argument 'bus'
Error

Line: 180 Column: 9

              can.setfilter(1, CAN.LIST16, 1, (5, 6, 7, 8))


def cb0(bus, reason):
    print("cb0")
    if reason == 0:
        print("pending")
    if reason == 1:
        print("full")

            

Reported by Pylint.

Redefining name 'bus' from outer scope (line 12)
Error

Line: 180 Column: 9

              can.setfilter(1, CAN.LIST16, 1, (5, 6, 7, 8))


def cb0(bus, reason):
    print("cb0")
    if reason == 0:
        print("pending")
    if reason == 1:
        print("full")

            

Reported by Pylint.

Redefining name 'bus' from outer scope (line 12)
Error

Line: 190 Column: 9

                      print("overflow")


def cb1(bus, reason):
    print("cb1")
    if reason == 0:
        print("pending")
    if reason == 1:
        print("full")

            

Reported by Pylint.

Unused argument 'bus'
Error

Line: 190 Column: 9

                      print("overflow")


def cb1(bus, reason):
    print("cb1")
    if reason == 0:
        print("pending")
    if reason == 1:
        print("full")

            

Reported by Pylint.

Redefining name 'bus' from outer scope (line 12)
Error

Line: 200 Column: 10

                      print("overflow")


def cb0a(bus, reason):
    print("cb0a")
    if reason == 0:
        print("pending")
    if reason == 1:
        print("full")

            

Reported by Pylint.

Unused argument 'bus'
Error

Line: 200 Column: 10

                      print("overflow")


def cb0a(bus, reason):
    print("cb0a")
    if reason == 0:
        print("pending")
    if reason == 1:
        print("full")

            

Reported by Pylint.

Unused argument 'bus'
Error

Line: 210 Column: 10

                      print("overflow")


def cb1a(bus, reason):
    print("cb1a")
    if reason == 0:
        print("pending")
    if reason == 1:
        print("full")

            

Reported by Pylint.

tests/multi_net/uasyncio_tcp_readinto.py
27 issues
Undefined variable 'multitest'
Error

Line: 44 Column: 5

                  ev = asyncio.Event()
    server = await asyncio.start_server(handle_connection, "0.0.0.0", PORT)
    print("server running")
    multitest.next()
    async with server:
        await asyncio.wait_for(ev.wait(), 10)


async def tcp_client():

            

Reported by Pylint.

Undefined variable 'IP'
Error

Line: 50 Column: 52

              

async def tcp_client():
    reader, writer = await asyncio.open_connection(IP, PORT)

    ba = bytearray(2)
    n = await reader.readinto(ba)
    print(n)
    print(ba[:n])

            

Reported by Pylint.

Undefined variable 'multitest'
Error

Line: 74 Column: 26

              

def instance0():
    multitest.globals(IP=multitest.get_network_ip())
    asyncio.run(tcp_server())


def instance1():
    multitest.next()

            

Reported by Pylint.

Undefined variable 'multitest'
Error

Line: 74 Column: 5

              

def instance0():
    multitest.globals(IP=multitest.get_network_ip())
    asyncio.run(tcp_server())


def instance1():
    multitest.next()

            

Reported by Pylint.

Undefined variable 'multitest'
Error

Line: 79 Column: 5

              

def instance1():
    multitest.next()
    asyncio.run(tcp_client())

            

Reported by Pylint.

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

Line: 10 Column: 9

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

try:
    import uarray as array
except ImportError:
    try:

            

Reported by Pylint.

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

Line: 19 Column: 9

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

PORT = 8000


async def handle_connection(reader, writer):

            

Reported by Pylint.

Unused argument 'reader'
Error

Line: 24 Column: 29

              PORT = 8000


async def handle_connection(reader, writer):
    writer.write(b"ab")
    await writer.drain()

    writer.write(b"c")
    await writer.drain()

            

Reported by Pylint.

Global variable 'ev' undefined at the module level
Error

Line: 40 Column: 5

              

async def tcp_server():
    global ev
    ev = asyncio.Event()
    server = await asyncio.start_server(handle_connection, "0.0.0.0", PORT)
    print("server running")
    multitest.next()
    async with server:

            

Reported by Pylint.

Possible binding to all interfaces.
Security

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

              async def tcp_server():
    global ev
    ev = asyncio.Event()
    server = await asyncio.start_server(handle_connection, "0.0.0.0", PORT)
    print("server running")
    multitest.next()
    async with server:
        await asyncio.wait_for(ev.wait(), 10)


            

Reported by Bandit.

tests/extmod/vfs_lfs_file.py
27 issues
Statement seems to have no effect
Error

Line: 6 Column: 5

              try:
    import uos

    uos.VfsLfs1
    uos.VfsLfs2
except (ImportError, AttributeError):
    print("SKIP")
    raise SystemExit


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 7 Column: 5

                  import uos

    uos.VfsLfs1
    uos.VfsLfs2
except (ImportError, AttributeError):
    print("SKIP")
    raise SystemExit



            

Reported by Pylint.

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

Line: 10 Column: 5

                  uos.VfsLfs2
except (ImportError, AttributeError):
    print("SKIP")
    raise SystemExit


class RAMBlockDevice:
    ERASE_BLOCK_SIZE = 1024


            

Reported by Pylint.

Unused argument 'arg'
Error

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.

Redefining name 'bdev' from outer scope (line 119)
Error

Line: 38 Column: 10

                          return 0


def test(bdev, vfs_class):
    print("test", vfs_class)

    # mkfs
    vfs_class.mkfs(bdev)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Test for VfsLittle using a RAM device, file IO

try:
    import uos

    uos.VfsLfs1
    uos.VfsLfs2
except (ImportError, AttributeError):
    print("SKIP")

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

                  raise SystemExit


class RAMBlockDevice:
    ERASE_BLOCK_SIZE = 1024

    def __init__(self, blocks):
        self.data = bytearray(blocks * self.ERASE_BLOCK_SIZE)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

                  def __init__(self, blocks):
        self.data = bytearray(blocks * self.ERASE_BLOCK_SIZE)

    def readblocks(self, block, buf, off):
        addr = block * self.ERASE_BLOCK_SIZE + off
        for i in range(len(buf)):
            buf[i] = self.data[addr + i]

    def writeblocks(self, block, buf, off):

            

Reported by Pylint.

Consider using enumerate instead of iterating with range and len
Error

Line: 21 Column: 9

              
    def readblocks(self, block, buf, off):
        addr = block * self.ERASE_BLOCK_SIZE + off
        for i in range(len(buf)):
            buf[i] = self.data[addr + i]

    def writeblocks(self, block, buf, off):
        addr = block * self.ERASE_BLOCK_SIZE + off
        for i in range(len(buf)):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                      for i in range(len(buf)):
            buf[i] = self.data[addr + i]

    def writeblocks(self, block, buf, off):
        addr = block * self.ERASE_BLOCK_SIZE + off
        for i in range(len(buf)):
            self.data[addr + i] = buf[i]

    def ioctl(self, op, arg):

            

Reported by Pylint.

tests/unicode/unicode_id.py
26 issues
function already defined line 7
Error

Line: 14 Column: 1

              print(α, αβγ, bβ, βb)

# function, argument, local identifiers
def α(β, γ):
    δ = β + γ
    print(β, γ, δ)


α(1, 2)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test unicode in identifiers

# comment
# αβγδϵφζ

# global identifiers
α = 1
αβγ = 2
bβ = 3

            

Reported by Pylint.

Constant name "α" contains a non-ASCII unicode character
Error

Line: 7 Column: 1

              # αβγδϵφζ

# global identifiers
α = 1
αβγ = 2
bβ = 3
βb = 4
print(α, αβγ, bβ, βb)


            

Reported by Pylint.

Constant name "αβγ" contains a non-ASCII unicode character
Error

Line: 8 Column: 1

              
# global identifiers
α = 1
αβγ = 2
bβ = 3
βb = 4
print(α, αβγ, bβ, βb)

# function, argument, local identifiers

            

Reported by Pylint.

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

Line: 9 Column: 1

              # global identifiers
α = 1
αβγ = 2
bβ = 3
βb = 4
print(α, αβγ, bβ, βb)

# function, argument, local identifiers
def α(β, γ):

            

Reported by Pylint.

Constant name "βb" contains a non-ASCII unicode character
Error

Line: 10 Column: 1

              α = 1
αβγ = 2
bβ = 3
βb = 4
print(α, αβγ, bβ, βb)

# function, argument, local identifiers
def α(β, γ):
    δ = β + γ

            

Reported by Pylint.

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

Line: 10 Column: 1

              α = 1
αβγ = 2
bβ = 3
βb = 4
print(α, αβγ, bβ, βb)

# function, argument, local identifiers
def α(β, γ):
    δ = β + γ

            

Reported by Pylint.

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

Line: 14 Column: 1

              print(α, αβγ, bβ, βb)

# function, argument, local identifiers
def α(β, γ):
    δ = β + γ
    print(β, γ, δ)


α(1, 2)

            

Reported by Pylint.

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

Line: 14 Column: 1

              print(α, αβγ, bβ, βb)

# function, argument, local identifiers
def α(β, γ):
    δ = β + γ
    print(β, γ, δ)


α(1, 2)

            

Reported by Pylint.

Argument name "β" contains a non-ASCII unicode character
Error

Line: 14 Column: 1

              print(α, αβγ, bβ, βb)

# function, argument, local identifiers
def α(β, γ):
    δ = β + γ
    print(β, γ, δ)


α(1, 2)

            

Reported by Pylint.

tests/basics/builtin_exec.py
26 issues
Using variable 'foo' before assignment
Error

Line: 10 Column: 7

                  raise SystemExit

print(exec("def foo(): return 42"))
print(foo())

d = {}
exec("def bar(): return 84", d)
print(d["bar"]())


            

Reported by Pylint.

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

Line: 7 Column: 5

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

print(exec("def foo(): return 42"))
print(foo())

d = {}

            

Reported by Pylint.

Use of exec detected.
Security

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

                  print("SKIP")
    raise SystemExit

print(exec("def foo(): return 42"))
print(foo())

d = {}
exec("def bar(): return 84", d)
print(d["bar"]())

            

Reported by Bandit.

Use of exec
Error

Line: 9 Column: 7

                  print("SKIP")
    raise SystemExit

print(exec("def foo(): return 42"))
print(foo())

d = {}
exec("def bar(): return 84", d)
print(d["bar"]())

            

Reported by Pylint.

Use of exec
Error

Line: 13 Column: 1

              print(foo())

d = {}
exec("def bar(): return 84", d)
print(d["bar"]())

# passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')

            

Reported by Pylint.

Use of exec detected.
Security

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

              print(foo())

d = {}
exec("def bar(): return 84", d)
print(d["bar"]())

# passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')

            

Reported by Bandit.

Use of exec detected.
Security

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

              
# passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')
exec('print(foo)', None)
exec('print(foo)', {'foo':3}, None)
exec('print(foo)', None, {'foo':3})
exec('print(foo)', None, {'bar':3})
exec('print(foo)', {'bar':3}, locals())

            

Reported by Bandit.

Use of exec
Error

Line: 18 Column: 1

              
# passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')
exec('print(foo)', None)
exec('print(foo)', {'foo':3}, None)
exec('print(foo)', None, {'foo':3})
exec('print(foo)', None, {'bar':3})
exec('print(foo)', {'bar':3}, locals())

            

Reported by Pylint.

Use of exec detected.
Security

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

              # passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')
exec('print(foo)', None)
exec('print(foo)', {'foo':3}, None)
exec('print(foo)', None, {'foo':3})
exec('print(foo)', None, {'bar':3})
exec('print(foo)', {'bar':3}, locals())


            

Reported by Bandit.

Use of exec
Error

Line: 19 Column: 1

              # passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')
exec('print(foo)', None)
exec('print(foo)', {'foo':3}, None)
exec('print(foo)', None, {'foo':3})
exec('print(foo)', None, {'bar':3})
exec('print(foo)', {'bar':3}, locals())


            

Reported by Pylint.

tests/misc/non_compliant.py
26 issues
Argument 'builtins.bytes' does not match format type 'c'
Error

Line: 44 Column: 5

              
# uPy raises TypeError, shold be ValueError
try:
    "%c" % b"\x01\x02"
except (TypeError, ValueError):
    print("TypeError, ValueError")

# attributes/subscr not implemented
try:

            

Reported by Pylint.

Inconsistent method resolution order for class 'B'
Error

Line: 143 Column: 1

                      print("A.foo")


class B(object, A):
    pass


B().foo()


            

Reported by Pylint.

class already defined line 138
Error

Line: 150 Column: 1

              B().foo()

# can't assign property (or other special accessors) to already-subclassed class
class A:
    pass


class B(A):
    pass

            

Reported by Pylint.

class already defined line 143
Error

Line: 154 Column: 1

                  pass


class B(A):
    pass


try:
    A.bar = property()

            

Reported by Pylint.

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

Line: 8 Column: 5

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

# when super can't find self
try:
    exec("def f(): super()")
except SyntaxError:

            

Reported by Pylint.

Use of exec
Error

Line: 12 Column: 5

              
# when super can't find self
try:
    exec("def f(): super()")
except SyntaxError:
    print("SyntaxError")

# store to exception attribute is not allowed
try:

            

Reported by Pylint.

Use of exec detected.
Security

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

              
# when super can't find self
try:
    exec("def f(): super()")
except SyntaxError:
    print("SyntaxError")

# store to exception attribute is not allowed
try:

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              # tests for things that are not implemented, or have non-compliant behaviour

try:
    import uarray as array
    import ustruct
except ImportError:
    print("SKIP")
    raise SystemExit


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 121 Column: 1

                  print("NotImplementedError")

# can't assign attributes to a function
def f():
    pass


try:
    f.x = 1

            

Reported by Pylint.

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

Line: 121 Column: 1

                  print("NotImplementedError")

# can't assign attributes to a function
def f():
    pass


try:
    f.x = 1

            

Reported by Pylint.