The following issues were found

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

Line: 12 Column: 5

                  t = A()[1:2]
except:
    print("SKIP")
    raise SystemExit


A()[1:2:3]

# test storing to attr (shouldn't be allowed)

            

Reported by Pylint.

Expression "A()[1:2:3]" is assigned to nothing
Error

Line: 15 Column: 1

                  raise SystemExit


A()[1:2:3]

# test storing to attr (shouldn't be allowed)
class B:
    def __getitem__(self, idx):
        try:

            

Reported by Pylint.

Expression "B()[:]" is assigned to nothing
Error

Line: 24 Column: 1

                          idx.start = 0
        except AttributeError:
            print('AttributeError')
B()[:]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test builtin slice attributes access

# print slice attributes
class A:
    def __getitem__(self, idx):
        print(idx.start, idx.stop, idx.step)

try:
    t = A()[1:2]

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 4 Column: 1

              # test builtin slice attributes access

# print slice attributes
class A:
    def __getitem__(self, idx):
        print(idx.start, idx.stop, idx.step)

try:
    t = A()[1:2]

            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              # test builtin slice attributes access

# print slice attributes
class A:
    def __getitem__(self, idx):
        print(idx.start, idx.stop, idx.step)

try:
    t = A()[1:2]

            

Reported by Pylint.

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

Line: 4 Column: 1

              # test builtin slice attributes access

# print slice attributes
class A:
    def __getitem__(self, idx):
        print(idx.start, idx.stop, idx.step)

try:
    t = A()[1:2]

            

Reported by Pylint.

Missing class docstring
Error

Line: 18 Column: 1

              A()[1:2:3]

# test storing to attr (shouldn't be allowed)
class B:
    def __getitem__(self, idx):
        try:
            idx.start = 0
        except AttributeError:
            print('AttributeError')

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 18 Column: 1

              A()[1:2:3]

# test storing to attr (shouldn't be allowed)
class B:
    def __getitem__(self, idx):
        try:
            idx.start = 0
        except AttributeError:
            print('AttributeError')

            

Reported by Pylint.

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

Line: 18 Column: 1

              A()[1:2:3]

# test storing to attr (shouldn't be allowed)
class B:
    def __getitem__(self, idx):
        try:
            idx.start = 0
        except AttributeError:
            print('AttributeError')

            

Reported by Pylint.

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

Line: 10 Column: 9

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


async def task(i, lock, lock_flag):
    print("task", i, "start")
    try:

            

Reported by Pylint.

Unused variable 't0'
Error

Line: 35 Column: 5

                  lock_flag = [True]

    # Create 4 tasks and let them all run
    t0 = asyncio.create_task(task(0, lock, lock_flag))
    t1 = asyncio.create_task(task(1, lock, lock_flag))
    t2 = asyncio.create_task(task(2, lock, lock_flag))
    t3 = asyncio.create_task(task(3, lock, lock_flag))
    await asyncio.sleep(0)


            

Reported by Pylint.

Unused variable 't3'
Error

Line: 38 Column: 5

                  t0 = asyncio.create_task(task(0, lock, lock_flag))
    t1 = asyncio.create_task(task(1, lock, lock_flag))
    t2 = asyncio.create_task(task(2, lock, lock_flag))
    t3 = asyncio.create_task(task(3, lock, lock_flag))
    await asyncio.sleep(0)

    # Cancel 2 of the tasks (which are waiting on the lock) and release the lock
    t1.cancel()
    t2.cancel()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Test that locks work when cancelling multiple waiters on the lock

try:
    import uasyncio as asyncio
except ImportError:
    try:
        import asyncio
    except ImportError:
        print("SKIP")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

                      raise SystemExit


async def task(i, lock, lock_flag):
    print("task", i, "start")
    try:
        await lock.acquire()
    except asyncio.CancelledError:
        print("task", i, "cancel")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

                  print("task", i, "done")


async def main():
    # Create a lock and acquire it so the tasks below must wait
    lock = asyncio.Lock()
    await lock.acquire()
    lock_flag = [True]


            

Reported by Pylint.

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

Line: 35 Column: 5

                  lock_flag = [True]

    # Create 4 tasks and let them all run
    t0 = asyncio.create_task(task(0, lock, lock_flag))
    t1 = asyncio.create_task(task(1, lock, lock_flag))
    t2 = asyncio.create_task(task(2, lock, lock_flag))
    t3 = asyncio.create_task(task(3, lock, lock_flag))
    await asyncio.sleep(0)


            

Reported by Pylint.

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

Line: 36 Column: 5

              
    # Create 4 tasks and let them all run
    t0 = asyncio.create_task(task(0, lock, lock_flag))
    t1 = asyncio.create_task(task(1, lock, lock_flag))
    t2 = asyncio.create_task(task(2, lock, lock_flag))
    t3 = asyncio.create_task(task(3, lock, lock_flag))
    await asyncio.sleep(0)

    # Cancel 2 of the tasks (which are waiting on the lock) and release the lock

            

Reported by Pylint.

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

Line: 37 Column: 5

                  # Create 4 tasks and let them all run
    t0 = asyncio.create_task(task(0, lock, lock_flag))
    t1 = asyncio.create_task(task(1, lock, lock_flag))
    t2 = asyncio.create_task(task(2, lock, lock_flag))
    t3 = asyncio.create_task(task(3, lock, lock_flag))
    await asyncio.sleep(0)

    # Cancel 2 of the tasks (which are waiting on the lock) and release the lock
    t1.cancel()

            

Reported by Pylint.

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

Line: 38 Column: 5

                  t0 = asyncio.create_task(task(0, lock, lock_flag))
    t1 = asyncio.create_task(task(1, lock, lock_flag))
    t2 = asyncio.create_task(task(2, lock, lock_flag))
    t3 = asyncio.create_task(task(3, lock, lock_flag))
    await asyncio.sleep(0)

    # Cancel 2 of the tasks (which are waiting on the lock) and release the lock
    t1.cancel()
    t2.cancel()

            

Reported by Pylint.

tests/internal_bench/func_args-3.2-kw_3.py
10 issues
Unused argument 'c'
Error

Line: 4 Column: 16

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Unused argument 'b'
Error

Line: 4 Column: 13

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Unused argument 'a'
Error

Line: 4 Column: 10

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Module name "2-kw_3" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

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

Line: 4 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

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

Line: 4 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

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

Line: 4 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

                  pass


def test(num):
    for i in iter(range(num)):
        func(c=i, b=i, a=i)


bench.run(test)

            

Reported by Pylint.

tests/micropython/viper_const.py
10 issues
Undefined variable 'micropython'
Error

Line: 4 Column: 2

              # test loading constants in viper functions


@micropython.viper
def f():
    return b"bytes"


print(f())

            

Reported by Pylint.

Undefined variable 'micropython'
Error

Line: 12 Column: 2

              print(f())


@micropython.viper
def f():
    @micropython.viper
    def g() -> int:
        return 123


            

Reported by Pylint.

function already defined line 5
Error

Line: 13 Column: 1

              

@micropython.viper
def f():
    @micropython.viper
    def g() -> int:
        return 123

    return g

            

Reported by Pylint.

Undefined variable 'micropython'
Error

Line: 14 Column: 6

              
@micropython.viper
def f():
    @micropython.viper
    def g() -> int:
        return 123

    return g


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test loading constants in viper functions


@micropython.viper
def f():
    return b"bytes"


print(f())

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              

@micropython.viper
def f():
    return b"bytes"


print(f())


            

Reported by Pylint.

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

Line: 5 Column: 1

              

@micropython.viper
def f():
    return b"bytes"


print(f())


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              

@micropython.viper
def f():
    @micropython.viper
    def g() -> int:
        return 123

    return g

            

Reported by Pylint.

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

Line: 13 Column: 1

              

@micropython.viper
def f():
    @micropython.viper
    def g() -> int:
        return 123

    return g

            

Reported by Pylint.

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

Line: 15 Column: 5

              @micropython.viper
def f():
    @micropython.viper
    def g() -> int:
        return 123

    return g



            

Reported by Pylint.

tests/thread/thread_lock4.py
10 issues
Redefining name 'i' from outer scope (line 41)
Error

Line: 14 Column: 9

              
def fac(n):
    x = 1
    for i in range(1, n + 1):
        x *= i
    return x


def thread_entry():

            

Reported by Pylint.

Redefining name 'arg' from outer scope (line 53)
Error

Line: 23 Column: 20

                  while True:
        with jobs_lock:
            try:
                f, arg = jobs.pop(0)
            except IndexError:
                return
        ans = f(arg)
        with output_lock:
            output.append((arg, ans))

            

Reported by Pylint.

Redefining name 'ans' from outer scope (line 53)
Error

Line: 26 Column: 9

                              f, arg = jobs.pop(0)
            except IndexError:
                return
        ans = f(arg)
        with output_lock:
            output.append((arg, ans))


# create a list of jobs

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test using lock to coordinate access to global mutable objects
#
# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd

try:
    import utime as time
except ImportError:
    import time
import _thread

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 1

              import _thread


def fac(n):
    x = 1
    for i in range(1, n + 1):
        x *= i
    return x


            

Reported by Pylint.

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

Line: 12 Column: 1

              import _thread


def fac(n):
    x = 1
    for i in range(1, n + 1):
        x *= i
    return x


            

Reported by Pylint.

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

Line: 13 Column: 5

              

def fac(n):
    x = 1
    for i in range(1, n + 1):
        x *= i
    return x



            

Reported by Pylint.

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

Line: 15 Column: 9

              def fac(n):
    x = 1
    for i in range(1, n + 1):
        x *= i
    return x


def thread_entry():
    while True:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 1

                  return x


def thread_entry():
    while True:
        with jobs_lock:
            try:
                f, arg = jobs.pop(0)
            except IndexError:

            

Reported by Pylint.

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

Line: 23 Column: 17

                  while True:
        with jobs_lock:
            try:
                f, arg = jobs.pop(0)
            except IndexError:
                return
        ans = f(arg)
        with output_lock:
            output.append((arg, ans))

            

Reported by Pylint.

tests/internal_bench/func_args-1.2-pos_3.py
10 issues
Unused argument 'a'
Error

Line: 4 Column: 10

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Unused argument 'c'
Error

Line: 4 Column: 16

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Unused argument 'b'
Error

Line: 4 Column: 13

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Module name "2-pos_3" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

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

Line: 4 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

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

Line: 4 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

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

Line: 4 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              import bench


def func(a, b, c):
    pass


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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

                  pass


def test(num):
    for i in iter(range(num)):
        func(i, i, i)


bench.run(test)

            

Reported by Pylint.

tests/micropython/heapalloc_yield_from.py
10 issues
Unable to import 'micropython'
Error

Line: 3 Column: 1

              # Check that yield-from can work without heap allocation

import micropython

# Yielding from a function generator
def sub_gen(a):
    for i in range(a):
        yield i


            

Reported by Pylint.

Redefining name 'g' from outer scope (line 15)
Error

Line: 11 Column: 9

                      yield i


def gen(g):
    yield from g


g = gen(sub_gen(4))
micropython.heap_lock()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Check that yield-from can work without heap allocation

import micropython

# Yielding from a function generator
def sub_gen(a):
    for i in range(a):
        yield i


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

              import micropython

# Yielding from a function generator
def sub_gen(a):
    for i in range(a):
        yield i


def gen(g):

            

Reported by Pylint.

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

Line: 6 Column: 1

              import micropython

# Yielding from a function generator
def sub_gen(a):
    for i in range(a):
        yield i


def gen(g):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

                      yield i


def gen(g):
    yield from g


g = gen(sub_gen(4))
micropython.heap_lock()

            

Reported by Pylint.

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

Line: 11 Column: 1

                      yield i


def gen(g):
    yield from g


g = gen(sub_gen(4))
micropython.heap_lock()

            

Reported by Pylint.

Missing class docstring
Error

Line: 22 Column: 1

              micropython.heap_unlock()

# Yielding from a user iterator
class G:
    def __init__(self):
        self.value = 0

    def __iter__(self):
        return self

            

Reported by Pylint.

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

Line: 22 Column: 1

              micropython.heap_unlock()

# Yielding from a user iterator
class G:
    def __init__(self):
        self.value = 0

    def __iter__(self):
        return self

            

Reported by Pylint.

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

Line: 30 Column: 9

                      return self

    def __next__(self):
        v = self.value
        self.value += 1
        return v


g = gen(G())

            

Reported by Pylint.

tests/internal_bench/func_args-2-pos_default_2_of_3.py
10 issues
Unused argument 'b'
Error

Line: 4 Column: 13

              import bench


def func(a, b=1, c=2):
    pass


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

            

Reported by Pylint.

Unused argument 'a'
Error

Line: 4 Column: 10

              import bench


def func(a, b=1, c=2):
    pass


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

            

Reported by Pylint.

Unused argument 'c'
Error

Line: 4 Column: 18

              import bench


def func(a, b=1, c=2):
    pass


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

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import bench


def func(a, b=1, c=2):
    pass


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

            

Reported by Pylint.

Module name "func_args-2-pos_default_2_of_3" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              import bench


def func(a, b=1, c=2):
    pass


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

            

Reported by Pylint.

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

Line: 4 Column: 1

              import bench


def func(a, b=1, c=2):
    pass


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

            

Reported by Pylint.

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

Line: 4 Column: 1

              import bench


def func(a, b=1, c=2):
    pass


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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              import bench


def func(a, b=1, c=2):
    pass


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

            

Reported by Pylint.

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

Line: 4 Column: 1

              import bench


def func(a, b=1, c=2):
    pass


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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

                  pass


def test(num):
    for i in iter(range(num)):
        func(i)


bench.run(test)

            

Reported by Pylint.

tests/basics/builtin_exec_buffer.py
9 issues
Statement seems to have no effect
Error

Line: 4 Column: 5

              # test builtin exec with a buffer (bytearray/memoryview) input

try:
    exec
    bytearray
    memoryview
except:
    print("SKIP")
    raise SystemExit

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 5 Column: 5

              
try:
    exec
    bytearray
    memoryview
except:
    print("SKIP")
    raise SystemExit


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 6 Column: 5

              try:
    exec
    bytearray
    memoryview
except:
    print("SKIP")
    raise SystemExit

exec(bytearray(b'print(1)'))

            

Reported by Pylint.

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

Line: 9 Column: 5

                  memoryview
except:
    print("SKIP")
    raise SystemExit

exec(bytearray(b'print(1)'))
exec(memoryview(b'print(2)'))

            

Reported by Pylint.

Use of exec detected.
Security

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

                  print("SKIP")
    raise SystemExit

exec(bytearray(b'print(1)'))
exec(memoryview(b'print(2)'))

            

Reported by Bandit.

Use of exec
Error

Line: 11 Column: 1

                  print("SKIP")
    raise SystemExit

exec(bytearray(b'print(1)'))
exec(memoryview(b'print(2)'))

            

Reported by Pylint.

Use of exec detected.
Security

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

                  raise SystemExit

exec(bytearray(b'print(1)'))
exec(memoryview(b'print(2)'))

            

Reported by Bandit.

Use of exec
Error

Line: 12 Column: 1

                  raise SystemExit

exec(bytearray(b'print(1)'))
exec(memoryview(b'print(2)'))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test builtin exec with a buffer (bytearray/memoryview) input

try:
    exec
    bytearray
    memoryview
except:
    print("SKIP")
    raise SystemExit

            

Reported by Pylint.

tests/basics/builtin_eval_buffer.py
9 issues
Statement seems to have no effect
Error

Line: 4 Column: 5

              # test builtin eval with a buffer (bytearray/memoryview) input

try:
    eval
    bytearray
    memoryview
except:
    print("SKIP")
    raise SystemExit

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 5 Column: 5

              
try:
    eval
    bytearray
    memoryview
except:
    print("SKIP")
    raise SystemExit


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 6 Column: 5

              try:
    eval
    bytearray
    memoryview
except:
    print("SKIP")
    raise SystemExit

print(eval(bytearray(b'1 + 1')))

            

Reported by Pylint.

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

Line: 9 Column: 5

                  memoryview
except:
    print("SKIP")
    raise SystemExit

print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))

            

Reported by Pylint.

Use of eval
Error

Line: 11 Column: 7

                  print("SKIP")
    raise SystemExit

print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))

            

Reported by Pylint.

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

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

                  print("SKIP")
    raise SystemExit

print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))

            

Reported by Bandit.

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

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

                  raise SystemExit

print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))

            

Reported by Bandit.

Use of eval
Error

Line: 12 Column: 7

                  raise SystemExit

print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test builtin eval with a buffer (bytearray/memoryview) input

try:
    eval
    bytearray
    memoryview
except:
    print("SKIP")
    raise SystemExit

            

Reported by Pylint.