The following issues were found

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

Line: 17 Column: 5

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

    yield from noop_task()

for z in main():

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

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

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

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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

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

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

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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

                  print('noop task')
    yield 1

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


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 1

                  print('raising')
    raise Exception

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


            

Reported by Pylint.

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

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

              
assert len(sys.argv) == 4

md5 = hashlib.md5()

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

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

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              import sys
import struct
import hashlib

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

            

Reported by Pylint.

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

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

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

assert len(sys.argv) == 4

md5 = hashlib.md5()

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


            

Reported by Bandit.

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

Line: 28 Column: 9

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

            

Reported by Pylint.

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

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

                      data_rom = f.read()

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

            

Reported by Bandit.

tests/basics/async_def.py
5 issues
Missing module docstring
Error

Line: 1 Column: 1

              # test async def

def dec(f):
    print('decorator')
    return f

# test definition with a decorator
@dec
async def foo():

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test async def

def dec(f):
    print('decorator')
    return f

# test definition with a decorator
@dec
async def foo():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # test async def

def dec(f):
    print('decorator')
    return f

# test definition with a decorator
@dec
async def foo():

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 9 Column: 1

              
# test definition with a decorator
@dec
async def foo():
    print('foo')

coro = foo()
try:
    coro.send(None)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              
# test definition with a decorator
@dec
async def foo():
    print('foo')

coro = foo()
try:
    coro.send(None)

            

Reported by Pylint.

tests/basics/async_await.py
5 issues
Missing module docstring
Error

Line: 1 Column: 1

              # test basic await expression
# adapted from PEP0492

async def abinary(n):
    print(n)
    if n <= 0:
        return 1
    l = await abinary(n - 1)
    r = await abinary(n - 1)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              # test basic await expression
# adapted from PEP0492

async def abinary(n):
    print(n)
    if n <= 0:
        return 1
    l = await abinary(n - 1)
    r = await abinary(n - 1)

            

Reported by Pylint.

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

Line: 4 Column: 1

              # test basic await expression
# adapted from PEP0492

async def abinary(n):
    print(n)
    if n <= 0:
        return 1
    l = await abinary(n - 1)
    r = await abinary(n - 1)

            

Reported by Pylint.

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

Line: 8 Column: 5

                  print(n)
    if n <= 0:
        return 1
    l = await abinary(n - 1)
    r = await abinary(n - 1)
    return l + 1 + r

o = abinary(4)
try:

            

Reported by Pylint.

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

Line: 9 Column: 5

                  if n <= 0:
        return 1
    l = await abinary(n - 1)
    r = await abinary(n - 1)
    return l + 1 + r

o = abinary(4)
try:
    while True:

            

Reported by Pylint.

tests/basics/async_await2.py
5 issues
Missing module docstring
Error

Line: 1 Column: 1

              # test await expression

try:
    import usys as sys
except ImportError:
    import sys
if sys.implementation.name == 'micropython':
    # uPy allows normal generators to be awaitables
    coroutine = lambda f: f

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

                  coroutine = types.coroutine

@coroutine
def wait(value):
    print('wait value:', value)
    msg = yield 'message from wait({})'.format(value)
    print('wait got back:', msg)
    return 10


            

Reported by Pylint.

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

Line: 21 Column: 1

                  print('wait got back:', msg)
    return 10

async def f():
    x = await wait(1)**2
    print('x =', x)

coro = f()
print('return from send:', coro.send(None))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 1

                  print('wait got back:', msg)
    return 10

async def f():
    x = await wait(1)**2
    print('x =', x)

coro = f()
print('return from send:', coro.send(None))

            

Reported by Pylint.

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

Line: 22 Column: 5

                  return 10

async def f():
    x = await wait(1)**2
    print('x =', x)

coro = f()
print('return from send:', coro.send(None))
try:

            

Reported by Pylint.

tests/basics/fun_annotations.py
5 issues
Black listed name "foo"
Error

Line: 1 Column: 1

              def foo(x: int, y: list) -> dict:
    return {x: y}

print(foo(1, [2, 3]))

            

Reported by Pylint.

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

Line: 1 Column: 1

              def foo(x: int, y: list) -> dict:
    return {x: y}

print(foo(1, [2, 3]))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 1 Column: 1

              def foo(x: int, y: list) -> dict:
    return {x: y}

print(foo(1, [2, 3]))

            

Reported by Pylint.

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

Line: 1 Column: 1

              def foo(x: int, y: list) -> dict:
    return {x: y}

print(foo(1, [2, 3]))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              def foo(x: int, y: list) -> dict:
    return {x: y}

print(foo(1, [2, 3]))

            

Reported by Pylint.

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/basics/for_else.py
5 issues
Else clause on loop without a break statement
Error

Line: 6 Column: 1

              # test optimised range with simple else
for i in range(2):
    print(i)
else:
    print('else')

# test optimised range with break over else
for i in range(2):
    print(i)

            

Reported by Pylint.

Else clause on loop without a break statement
Error

Line: 21 Column: 5

                  print(i)
    for j in range(4):
        pass
    else:
        continue
    break

# test optimised range with non-constant end value
N = 2

            

Reported by Pylint.

Else clause on loop without a break statement
Error

Line: 29 Column: 1

              N = 2
for i in range(N):
    print(i)
else:
    print('else')

# test generic iterator with simple else
for i in [0, 1]:
    print(i)

            

Reported by Pylint.

Else clause on loop without a break statement
Error

Line: 35 Column: 1

              # test generic iterator with simple else
for i in [0, 1]:
    print(i)
else:
    print('else')

# test generic iterator with break over else
for i in [0, 1]:
    print(i)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test for-else statement

# test optimised range with simple else
for i in range(2):
    print(i)
else:
    print('else')

# test optimised range with break over else

            

Reported by Pylint.

tests/basics/floordivide_intbig.py
5 issues
Missing module docstring
Error

Line: 1 Column: 1

              # check modulo matches python definition

a = 987654321987987987987987987987
b = 19

print(a // b)
print(a // -b)
print(-a // b)
print(-a // -b)

            

Reported by Pylint.

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

Line: 3 Column: 1

              # check modulo matches python definition

a = 987654321987987987987987987987
b = 19

print(a // b)
print(a // -b)
print(-a // b)
print(-a // -b)

            

Reported by Pylint.

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

Line: 4 Column: 1

              # check modulo matches python definition

a = 987654321987987987987987987987
b = 19

print(a // b)
print(a // -b)
print(-a // b)
print(-a // -b)

            

Reported by Pylint.

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

Line: 10 Column: 1

              print(a // -b)
print(-a // b)
print(-a // -b)
a = 10000000000000000000000000000000000000000000
b = 100
print(a // b)
print(a // -b)
print(-a // b)
print(-a // -b)

            

Reported by Pylint.

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

Line: 11 Column: 1

              print(-a // b)
print(-a // -b)
a = 10000000000000000000000000000000000000000000
b = 100
print(a // b)
print(a // -b)
print(-a // b)
print(-a // -b)

            

Reported by Pylint.

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

Line: 7 Column: 5

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

# check that constants exist and are integers
print(type(uerrno.EIO))

# check that errors are rendered in a nice way

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test errno's and uerrno module

try:
    import uerrno
except ImportError:
    print("SKIP")
    raise SystemExit

# check that constants exist and are integers

            

Reported by Pylint.

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

Line: 13 Column: 1

              print(type(uerrno.EIO))

# check that errors are rendered in a nice way
msg = str(OSError(uerrno.EIO))
print(msg[:7], msg[-5:])
msg = str(OSError(uerrno.EIO, "details"))
print(msg[:7], msg[-14:])
msg = str(OSError(uerrno.EIO, "details", "more details"))
print(msg[:1], msg[-28:])

            

Reported by Pylint.

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

Line: 15 Column: 1

              # check that errors are rendered in a nice way
msg = str(OSError(uerrno.EIO))
print(msg[:7], msg[-5:])
msg = str(OSError(uerrno.EIO, "details"))
print(msg[:7], msg[-14:])
msg = str(OSError(uerrno.EIO, "details", "more details"))
print(msg[:1], msg[-28:])

# check that unknown errno is still rendered

            

Reported by Pylint.

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

Line: 17 Column: 1

              print(msg[:7], msg[-5:])
msg = str(OSError(uerrno.EIO, "details"))
print(msg[:7], msg[-14:])
msg = str(OSError(uerrno.EIO, "details", "more details"))
print(msg[:1], msg[-28:])

# check that unknown errno is still rendered
print(str(OSError(9999)))


            

Reported by Pylint.