The following issues were found

ports/esp8266/modules/_boot.py
8 issues
Module 'gc' has no 'threshold' member
Error

Line: 3 Column: 1

              import gc

gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
import uos
from flashbdev import bdev

if bdev:
    try:
        uos.mount(bdev, "/")

            

Reported by Pylint.

Module 'gc' has no 'mem_free' member
Error

Line: 3 Column: 15

              import gc

gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
import uos
from flashbdev import bdev

if bdev:
    try:
        uos.mount(bdev, "/")

            

Reported by Pylint.

Module 'gc' has no 'mem_alloc' member
Error

Line: 3 Column: 31

              import gc

gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
import uos
from flashbdev import bdev

if bdev:
    try:
        uos.mount(bdev, "/")

            

Reported by Pylint.

Unable to import 'uos'
Error

Line: 4 Column: 1

              import gc

gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
import uos
from flashbdev import bdev

if bdev:
    try:
        uos.mount(bdev, "/")

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 10 Column: 5

              if bdev:
    try:
        uos.mount(bdev, "/")
    except:
        import inisetup

        inisetup.setup()

gc.collect()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import gc

gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
import uos
from flashbdev import bdev

if bdev:
    try:
        uos.mount(bdev, "/")

            

Reported by Pylint.

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

Line: 4 Column: 1

              import gc

gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
import uos
from flashbdev import bdev

if bdev:
    try:
        uos.mount(bdev, "/")

            

Reported by Pylint.

Import "from flashbdev import bdev" should be placed at the top of the module
Error

Line: 5 Column: 1

              
gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
import uos
from flashbdev import bdev

if bdev:
    try:
        uos.mount(bdev, "/")
    except:

            

Reported by Pylint.

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

Line: 11 Column: 9

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


async def task_a():
    try:
        while True:

            

Reported by Pylint.

Redefining built-in 'id'
Error

Line: 23 Column: 18

                      print("cancelled a")


async def task_b(id, other):
    while other.cancel():
        print("sleep b", id)
        await asyncio.sleep(0)
    print("done b", id)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Test fairness of cancelling a task
# That tasks which keeps being cancelled by multiple other tasks gets a chance to run

try:
    import uasyncio as asyncio
except ImportError:
    try:
        import asyncio
    except ImportError:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 1

                      raise SystemExit


async def task_a():
    try:
        while True:
            print("sleep a")
            await asyncio.sleep(0)
    except asyncio.CancelledError:

            

Reported by Pylint.

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

Line: 23 Column: 1

                      print("cancelled a")


async def task_b(id, other):
    while other.cancel():
        print("sleep b", id)
        await asyncio.sleep(0)
    print("done b", id)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 1

                      print("cancelled a")


async def task_b(id, other):
    while other.cancel():
        print("sleep b", id)
        await asyncio.sleep(0)
    print("done b", id)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 1

                  print("done b", id)


async def main():
    t = asyncio.create_task(task_a())
    for i in range(3):
        asyncio.create_task(task_b(i, t))
    await t


            

Reported by Pylint.

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

Line: 31 Column: 5

              

async def main():
    t = asyncio.create_task(task_a())
    for i in range(3):
        asyncio.create_task(task_b(i, t))
    await t



            

Reported by Pylint.

tests/basics/struct_micropython.py
8 issues
Unable to import 'ustruct'
Error

Line: 4 Column: 5

              # test MicroPython-specific features of struct

try:
    import ustruct as struct
except:
    try:
        import struct
    except ImportError:
        print("SKIP")

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 5 Column: 1

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

            

Reported by Pylint.

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

Line: 10 Column: 9

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

class A():
    pass

# pack and unpack objects

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test MicroPython-specific features of struct

try:
    import ustruct as struct
except:
    try:
        import struct
    except ImportError:
        print("SKIP")

            

Reported by Pylint.

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

Line: 12 Column: 1

                      print("SKIP")
        raise SystemExit

class A():
    pass

# pack and unpack objects
o = A()
s = struct.pack("<O", o)

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

                      print("SKIP")
        raise SystemExit

class A():
    pass

# pack and unpack objects
o = A()
s = struct.pack("<O", o)

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 12 Column: 1

                      print("SKIP")
        raise SystemExit

class A():
    pass

# pack and unpack objects
o = A()
s = struct.pack("<O", o)

            

Reported by Pylint.

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

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

                  o = uctypes.addressof('abc')
    s = struct.pack("<S", o)
    o2 = struct.unpack("<S", s)
    assert o2[0] == 'abc'
except ImportError:
    pass

            

Reported by Bandit.

tests/basics/async_for2.py
8 issues
Missing module docstring
Error

Line: 1 Column: 1

              # test waiting within "async for" __anext__ function

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 f(x):
    print('f start:', x)
    yield x + 1
    yield x + 2
    return x + 3


            

Reported by Pylint.

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

Line: 15 Column: 1

                  coroutine = types.coroutine

@coroutine
def f(x):
    print('f start:', x)
    yield x + 1
    yield x + 2
    return x + 3


            

Reported by Pylint.

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

Line: 15 Column: 1

                  coroutine = types.coroutine

@coroutine
def f(x):
    print('f start:', x)
    yield x + 1
    yield x + 2
    return x + 3


            

Reported by Pylint.

Missing class docstring
Error

Line: 21 Column: 1

                  yield x + 2
    return x + 3

class ARange:
    def __init__(self, high):
        print('init')
        self.cur = 0
        self.high = high


            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 34 Column: 9

                  async def __anext__(self):
        print('anext')
        print('f returned:', await f(20))
        if self.cur < self.high:
            val = self.cur
            self.cur += 1
            return val
        else:
            raise StopAsyncIteration

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 41 Column: 1

                      else:
            raise StopAsyncIteration

async def coro():
    async for x in ARange(4):
        print('x', x)

o = coro()
try:

            

Reported by Pylint.

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

Line: 42 Column: 15

                          raise StopAsyncIteration

async def coro():
    async for x in ARange(4):
        print('x', x)

o = coro()
try:
    while True:

            

Reported by Pylint.

tests/micropython/native_gen.py
8 issues
Undefined variable 'micropython'
Error

Line: 4 Column: 2

              # test for native generators

# simple generator with yield and return
@micropython.native
def gen1(x):
    yield x
    yield x + 1
    return x + 2


            

Reported by Pylint.

Undefined variable 'micropython'
Error

Line: 20 Column: 2

                  print(e.args[0])

# using yield from
@micropython.native
def gen2(x):
    yield from range(x)


print(list(gen2(3)))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test for native generators

# simple generator with yield and return
@micropython.native
def gen1(x):
    yield x
    yield x + 1
    return x + 2


            

Reported by Pylint.

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

Line: 5 Column: 1

              
# simple generator with yield and return
@micropython.native
def gen1(x):
    yield x
    yield x + 1
    return x + 2



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              
# simple generator with yield and return
@micropython.native
def gen1(x):
    yield x
    yield x + 1
    return x + 2



            

Reported by Pylint.

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

Line: 16 Column: 1

              print(next(g))
try:
    next(g)
except StopIteration as e:
    print(e.args[0])

# using yield from
@micropython.native
def gen2(x):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 1

              
# using yield from
@micropython.native
def gen2(x):
    yield from range(x)


print(list(gen2(3)))

            

Reported by Pylint.

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

Line: 21 Column: 1

              
# using yield from
@micropython.native
def gen2(x):
    yield from range(x)


print(list(gen2(3)))

            

Reported by Pylint.

tests/basics/assign1.py
8 issues
Missing module docstring
Error

Line: 1 Column: 1

              # test assignments

a = 1
print(a)

a = b = 2
print(a, b)

a = b = c = 3

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test assignments

a = 1
print(a)

a = b = 2
print(a, b)

a = b = c = 3

            

Reported by Pylint.

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

Line: 6 Column: 5

              a = 1
print(a)

a = b = 2
print(a, b)

a = b = c = 3
print(a, b, c)


            

Reported by Pylint.

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

Line: 6 Column: 1

              a = 1
print(a)

a = b = 2
print(a, b)

a = b = c = 3
print(a, b, c)


            

Reported by Pylint.

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

Line: 9 Column: 5

              a = b = 2
print(a, b)

a = b = c = 3
print(a, b, c)


            

Reported by Pylint.

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

Line: 9 Column: 9

              a = b = 2
print(a, b)

a = b = c = 3
print(a, b, c)


            

Reported by Pylint.

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

Line: 9 Column: 1

              a = b = 2
print(a, b)

a = b = c = 3
print(a, b, c)


            

Reported by Pylint.

Trailing newlines
Error

Line: 11 Column: 1

              
a = b = c = 3
print(a, b, c)


            

Reported by Pylint.

tests/basics/fun_defargs2.py
8 issues
Missing module docstring
Error

Line: 1 Column: 1

              # overriding default arguments

def foo(a, b=3):
    print(a, b)

# override with positional
foo(1, 333)

# override with keyword

            

Reported by Pylint.

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

Line: 3 Column: 1

              # overriding default arguments

def foo(a, b=3):
    print(a, b)

# override with positional
foo(1, 333)

# override with keyword

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # overriding default arguments

def foo(a, b=3):
    print(a, b)

# override with positional
foo(1, 333)

# override with keyword

            

Reported by Pylint.

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

Line: 3 Column: 1

              # overriding default arguments

def foo(a, b=3):
    print(a, b)

# override with positional
foo(1, 333)

# override with keyword

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 3 Column: 1

              # overriding default arguments

def foo(a, b=3):
    print(a, b)

# override with positional
foo(1, 333)

# override with keyword

            

Reported by Pylint.

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

Line: 15 Column: 1

              # override with keyword
foo(a=2, b=333)

def foo2(a=1, b=2):
    print(a, b)

# default and keyword
foo2(b='two')

            

Reported by Pylint.

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

Line: 15 Column: 1

              # override with keyword
foo(a=2, b=333)

def foo2(a=1, b=2):
    print(a, b)

# default and keyword
foo2(b='two')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

              # override with keyword
foo(a=2, b=333)

def foo2(a=1, b=2):
    print(a, b)

# default and keyword
foo2(b='two')

            

Reported by Pylint.

tests/basics/annotate_var.py
8 issues
function already defined line 13
Error

Line: 22 Column: 1

              f()

# here, "x" should remain a global
def f():
    x.y: int
    print(x)
f()

            

Reported by Pylint.

Redefining name 'x' from outer scope (line 3)
Error

Line: 14 Column: 5

              
# a pure annotation in a function makes that variable local
def f():
    x: int
    try:
        print(x)
    except NameError:
        print("NameError")
f()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test PEP 526, varible annotations

x: int
print("x" in globals())

x: int = 1
print(x)

t: tuple = 1, 2

            

Reported by Pylint.

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

Line: 13 Column: 1

              print(t)

# a pure annotation in a function makes that variable local
def f():
    x: int
    try:
        print(x)
    except NameError:
        print("NameError")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              print(t)

# a pure annotation in a function makes that variable local
def f():
    x: int
    try:
        print(x)
    except NameError:
        print("NameError")

            

Reported by Pylint.

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

Line: 14 Column: 5

              
# a pure annotation in a function makes that variable local
def f():
    x: int
    try:
        print(x)
    except NameError:
        print("NameError")
f()

            

Reported by Pylint.

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

Line: 22 Column: 1

              f()

# here, "x" should remain a global
def f():
    x.y: int
    print(x)
f()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 1

              f()

# here, "x" should remain a global
def f():
    x.y: int
    print(x)
f()

            

Reported by Pylint.

examples/network/http_server.py
8 issues
No exception type(s) specified
Error

Line: 3 Column: 1

              try:
    import usocket as socket
except:
    import socket


CONTENT = b"""\
HTTP/1.0 200 OK


            

Reported by Pylint.

Possible binding to all interfaces.
Security

Line: 18
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", 8080)
    print("Bind address info:", ai)
    addr = ai[0][-1]

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

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    import usocket as socket
except:
    import socket


CONTENT = b"""\
HTTP/1.0 200 OK


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 1

              """


def main(micropython_optimize=False):
    s = socket.socket()

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

            

Reported by Pylint.

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

Line: 15 Column: 5

              

def main(micropython_optimize=False):
    s = socket.socket()

    # Binding to all interfaces - server will be accessible to other hosts!
    ai = socket.getaddrinfo("0.0.0.0", 8080)
    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: 18 Column: 5

                  s = socket.socket()

    # Binding to all interfaces - server will be accessible to other hosts!
    ai = socket.getaddrinfo("0.0.0.0", 8080)
    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: 52 Column: 13

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


            

Reported by Pylint.

Consider merging these comparisons with "in" to "h in (b'', b'\\r\\n')"
Error

Line: 53 Column: 16

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

        client_stream.close()

            

Reported by Pylint.

tests/basics/exceptpoly2.py
8 issues
Catching too general exception Exception
Error

Line: 3 Column: 8

              try:
    raise MemoryError
except Exception:
    print("Caught MemoryError via Exception")

try:
    raise MemoryError
except MemoryError:
    print("Caught MemoryError")

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 13 Column: 8

              
try:
    raise NameError
except Exception:
    print("Caught NameError via Exception")

try:
    raise NameError
except NameError:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 33 Column: 8

              
try:
    raise OSError
except Exception:
    print("Caught OSError via Exception")

try:
    raise OSError
except OSError:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 53 Column: 8

              
try:
    raise RuntimeError
except Exception:
    print("Caught RuntimeError via Exception")

try:
    raise RuntimeError
except RuntimeError:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 63 Column: 8

              
try:
    raise SyntaxError
except Exception:
    print("Caught SyntaxError via Exception")

try:
    raise SyntaxError
except SyntaxError:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 73 Column: 8

              
try:
    raise TypeError
except Exception:
    print("Caught TypeError via Exception")

try:
    raise TypeError
except TypeError:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 83 Column: 8

              
try:
    raise ValueError
except Exception:
    print("Caught ValueError via Exception")

try:
    raise ValueError
except ValueError:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    raise MemoryError
except Exception:
    print("Caught MemoryError via Exception")

try:
    raise MemoryError
except MemoryError:
    print("Caught MemoryError")

            

Reported by Pylint.