The following issues were found

tests/basics/assign_expr.py
7 issues
Undefined variable 'm'
Error

Line: 29 Column: 7

              print(hit)  # should be changed by above

print([((m := k + 1), k * m) for k in range(4)])
print(m)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 1 Column: 1

              (x := 4)
print(x)

if x := 2:
    print(True)
print(x)

print(4, x := 5)
print(x)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              (x := 4)
print(x)

if x := 2:
    print(True)
print(x)

print(4, x := 5)
print(x)

            

Reported by Pylint.

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

Line: 11 Column: 1

              print(4, x := 5)
print(x)

x = 1
print(x, x := 5, x)
print(x)


def foo():

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 16 Column: 1

              print(x)


def foo():
    print("any", any((hit := i) % 5 == 3 and (hit % 2) == 0 for i in range(10)))
    return hit


hit = 123

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 1

              print(x)


def foo():
    print("any", any((hit := i) % 5 == 3 and (hit % 2) == 0 for i in range(10)))
    return hit


hit = 123

            

Reported by Pylint.

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

Line: 21 Column: 1

                  return hit


hit = 123
print(foo())
print(hit)  # shouldn't be changed by foo

print("any", any((hit := i) % 5 == 3 and (hit % 2) == 0 for i in range(10)))
print(hit)  # should be changed by above

            

Reported by Pylint.

tests/micropython/heapalloc_exc_compressed_emg_exc.py
7 issues
Unable to import 'micropython'
Error

Line: 1 Column: 1

              import micropython

# Does the full test from heapalloc_exc_compressed.py but while the heap is
# locked (this can only work when the emergency exception buf is enabled).

# Some ports need to allocate heap for the emgergency exception buffer.
try:
    micropython.alloc_emergency_exception_buf(256)
except AttributeError:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import micropython

# Does the full test from heapalloc_exc_compressed.py but while the heap is
# locked (this can only work when the emergency exception buf is enabled).

# Some ports need to allocate heap for the emgergency exception buffer.
try:
    micropython.alloc_emergency_exception_buf(256)
except AttributeError:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

              a = set()


def test():
    micropython.heap_lock()

    try:
        name()
    except NameError as e:

            

Reported by Pylint.

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

Line: 20 Column: 5

              
    try:
        name()
    except NameError as e:
        print(type(e).__name__, e)

    try:
        a.pop()
    except KeyError as e:

            

Reported by Pylint.

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

Line: 25 Column: 5

              
    try:
        a.pop()
    except KeyError as e:
        print(type(e).__name__, e)

    try:
        name()
    except NameError as e:

            

Reported by Pylint.

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

Line: 30 Column: 5

              
    try:
        name()
    except NameError as e:
        print(e.args[0])

    try:
        a.pop()
    except KeyError as e:

            

Reported by Pylint.

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

Line: 35 Column: 5

              
    try:
        a.pop()
    except KeyError as e:
        print(e.args[0])

    micropython.heap_unlock()



            

Reported by Pylint.

tests/basics/fun_calldblstar3.py
7 issues
Missing module docstring
Error

Line: 1 Column: 1

              # test passing a user-defined mapping as the argument to **

def foo(**kw):
    print(sorted(kw.items()))

class Mapping:
    def keys(self):
        # the long string checks the case of string interning
        return ['a', 'b', 'c', 'abcdefghijklmnopqrst']

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 3 Column: 1

              # test passing a user-defined mapping as the argument to **

def foo(**kw):
    print(sorted(kw.items()))

class Mapping:
    def keys(self):
        # the long string checks the case of string interning
        return ['a', 'b', 'c', 'abcdefghijklmnopqrst']

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # test passing a user-defined mapping as the argument to **

def foo(**kw):
    print(sorted(kw.items()))

class Mapping:
    def keys(self):
        # the long string checks the case of string interning
        return ['a', 'b', 'c', 'abcdefghijklmnopqrst']

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              def foo(**kw):
    print(sorted(kw.items()))

class Mapping:
    def keys(self):
        # the long string checks the case of string interning
        return ['a', 'b', 'c', 'abcdefghijklmnopqrst']

    def __getitem__(self, key):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 5

                  print(sorted(kw.items()))

class Mapping:
    def keys(self):
        # the long string checks the case of string interning
        return ['a', 'b', 'c', 'abcdefghijklmnopqrst']

    def __getitem__(self, key):
        if key == 'a':

            

Reported by Pylint.

Method could be a function
Error

Line: 7 Column: 5

                  print(sorted(kw.items()))

class Mapping:
    def keys(self):
        # the long string checks the case of string interning
        return ['a', 'b', 'c', 'abcdefghijklmnopqrst']

    def __getitem__(self, key):
        if key == 'a':

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 12 Column: 9

                      return ['a', 'b', 'c', 'abcdefghijklmnopqrst']

    def __getitem__(self, key):
        if key == 'a':
            return 1
        else:
            return 2

foo(**Mapping())

            

Reported by Pylint.

tests/thread/thread_ident1.py
7 issues
Using the global statement
Error

Line: 11 Column: 5

              def thread_entry():
    tid = _thread.get_ident()
    print("thread", type(tid) == int, tid != 0, tid != tid_main)
    global finished
    finished = True


tid_main = _thread.get_ident()
print("main", type(tid_main) == int, tid_main != 0)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test _thread.get_ident() function
#
# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd

import _thread


def thread_entry():
    tid = _thread.get_ident()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              import _thread


def thread_entry():
    tid = _thread.get_ident()
    print("thread", type(tid) == int, tid != 0, tid != tid_main)
    global finished
    finished = True


            

Reported by Pylint.

Using type() instead of isinstance() for a typecheck.
Error

Line: 10 Column: 21

              
def thread_entry():
    tid = _thread.get_ident()
    print("thread", type(tid) == int, tid != 0, tid != tid_main)
    global finished
    finished = True


tid_main = _thread.get_ident()

            

Reported by Pylint.

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

Line: 11 Column: 5

              def thread_entry():
    tid = _thread.get_ident()
    print("thread", type(tid) == int, tid != 0, tid != tid_main)
    global finished
    finished = True


tid_main = _thread.get_ident()
print("main", type(tid_main) == int, tid_main != 0)

            

Reported by Pylint.

Using type() instead of isinstance() for a typecheck.
Error

Line: 16 Column: 15

              

tid_main = _thread.get_ident()
print("main", type(tid_main) == int, tid_main != 0)

finished = False
_thread.start_new_thread(thread_entry, ())

while not finished:

            

Reported by Pylint.

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

Line: 18 Column: 1

              tid_main = _thread.get_ident()
print("main", type(tid_main) == int, tid_main != 0)

finished = False
_thread.start_new_thread(thread_entry, ())

while not finished:
    pass
print("done")

            

Reported by Pylint.

tests/basics/fun2.py
7 issues
Missing module docstring
Error

Line: 1 Column: 1

              # calling a function from a function

def f(x):
    print(x + 1)

def g(x):
    f(2 * x)
    f(4 * x)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # calling a function from a function

def f(x):
    print(x + 1)

def g(x):
    f(2 * x)
    f(4 * x)


            

Reported by Pylint.

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

Line: 3 Column: 1

              # calling a function from a function

def f(x):
    print(x + 1)

def g(x):
    f(2 * x)
    f(4 * x)


            

Reported by Pylint.

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

Line: 3 Column: 1

              # calling a function from a function

def f(x):
    print(x + 1)

def g(x):
    f(2 * x)
    f(4 * x)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

              def f(x):
    print(x + 1)

def g(x):
    f(2 * x)
    f(4 * x)

g(3)

            

Reported by Pylint.

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

Line: 6 Column: 1

              def f(x):
    print(x + 1)

def g(x):
    f(2 * x)
    f(4 * x)

g(3)

            

Reported by Pylint.

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

Line: 6 Column: 1

              def f(x):
    print(x + 1)

def g(x):
    f(2 * x)
    f(4 * x)

g(3)

            

Reported by Pylint.

tests/basics/for1.py
7 issues
Missing module docstring
Error

Line: 1 Column: 1

              # basic for loop

def f():
    for x in range(2):
        for y in range(2):
            for z in range(2):
                print(x, y, z)

f()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # basic for loop

def f():
    for x in range(2):
        for y in range(2):
            for z in range(2):
                print(x, y, z)

f()

            

Reported by Pylint.

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

Line: 3 Column: 1

              # basic for loop

def f():
    for x in range(2):
        for y in range(2):
            for z in range(2):
                print(x, y, z)

f()

            

Reported by Pylint.

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

Line: 4 Column: 9

              # basic for loop

def f():
    for x in range(2):
        for y in range(2):
            for z in range(2):
                print(x, y, z)

f()

            

Reported by Pylint.

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

Line: 5 Column: 13

              
def f():
    for x in range(2):
        for y in range(2):
            for z in range(2):
                print(x, y, z)

f()


            

Reported by Pylint.

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

Line: 6 Column: 17

              def f():
    for x in range(2):
        for y in range(2):
            for z in range(2):
                print(x, y, z)

f()

# range with negative step

            

Reported by Pylint.

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

Line: 15 Column: 1

              for i in range(3, -1, -1):
    print(i)

a = -1
# range with non-constant step - we optimize constant steps, so this
# will be executed differently
for i in range(3, -1, a):
    print(i)

            

Reported by Pylint.

examples/network/http_server_simplistic.py
7 issues
No exception type(s) specified
Error

Line: 5 Column: 1

              # http_server_simplistic_commented.py for details.
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

              
def main():
    s = socket.socket()
    ai = socket.getaddrinfo("0.0.0.0", 8080)
    addr = ai[0][-1]

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

    s.bind(addr)

            

Reported by Bandit.

Unused variable 'client_addr'
Error

Line: 31 Column: 9

                  while True:
        res = s.accept()
        client_s = res[0]
        client_addr = res[1]
        req = client_s.recv(4096)
        print("Request:")
        print(req)
        client_s.send(CONTENT % counter)
        client_s.close()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Do not use this code in real projects! Read
# http_server_simplistic_commented.py for details.
try:
    import usocket as socket
except:
    import socket


CONTENT = b"""\

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 1

              """


def main():
    s = socket.socket()
    ai = socket.getaddrinfo("0.0.0.0", 8080)
    addr = ai[0][-1]

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

            

Reported by Pylint.

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

Line: 17 Column: 5

              

def main():
    s = socket.socket()
    ai = socket.getaddrinfo("0.0.0.0", 8080)
    addr = ai[0][-1]

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


            

Reported by Pylint.

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

Line: 18 Column: 5

              
def main():
    s = socket.socket()
    ai = socket.getaddrinfo("0.0.0.0", 8080)
    addr = ai[0][-1]

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

    s.bind(addr)

            

Reported by Pylint.

tests/micropython/const.py
7 issues
Unable to import 'micropython'
Error

Line: 3 Column: 1

              # test constant optimisation

from micropython import const

X = const(123)
Y = const(X + 456)

print(X, Y + 1)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test constant optimisation

from micropython import const

X = const(123)
Y = const(X + 456)

print(X, Y + 1)


            

Reported by Pylint.

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

Line: 11 Column: 1

              print(X, Y + 1)


def f():
    print(X, Y + 1)


f()


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

              print(X, Y + 1)


def f():
    print(X, Y + 1)


f()


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 23 Column: 1

              print(_X, _Y)


class A:
    Z = const(1)
    _Z = const(2)
    print(Z, _Z)



            

Reported by Pylint.

Missing class docstring
Error

Line: 23 Column: 1

              print(_X, _Y)


class A:
    Z = const(1)
    _Z = const(2)
    print(Z, _Z)



            

Reported by Pylint.

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

Line: 23 Column: 1

              print(_X, _Y)


class A:
    Z = const(1)
    _Z = const(2)
    print(Z, _Z)



            

Reported by Pylint.

tests/basics/try_finally_return5.py
7 issues
Statement seems to have no effect
Error

Line: 11 Column: 25

                                  print(x, i)
                finally:
                    try:
                        1 / 0
                    finally:
                        return 42
            finally:
                print('return')
                return 43

            

Reported by Pylint.

return statement in finally block may swallow exception
Error

Line: 13 Column: 25

                                  try:
                        1 / 0
                    finally:
                        return 42
            finally:
                print('return')
                return 43
print(foo(4))

            

Reported by Pylint.

return statement in finally block may swallow exception
Error

Line: 16 Column: 17

                                      return 42
            finally:
                print('return')
                return 43
print(foo(4))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              def foo(x):
    for i in range(x):
        try:
            pass
        finally:
            try:
                try:
                    print(x, i)
                finally:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 1 Column: 1

              def foo(x):
    for i in range(x):
        try:
            pass
        finally:
            try:
                try:
                    print(x, i)
                finally:

            

Reported by Pylint.

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

Line: 1 Column: 1

              def foo(x):
    for i in range(x):
        try:
            pass
        finally:
            try:
                try:
                    print(x, i)
                finally:

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 1 Column: 1

              def foo(x):
    for i in range(x):
        try:
            pass
        finally:
            try:
                try:
                    print(x, i)
                finally:

            

Reported by Pylint.

tests/thread/stress_recurse.py
7 issues
Using the global statement
Error

Line: 17 Column: 5

                      foo()
    except RuntimeError:
        print("RuntimeError")
    global finished
    finished = True


finished = False


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test hitting the function recursion limit within a thread
#
# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd

import _thread


def foo():
    foo()

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 8 Column: 1

              import _thread


def foo():
    foo()


def thread_entry():
    try:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              import _thread


def foo():
    foo()


def thread_entry():
    try:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 1

                  foo()


def thread_entry():
    try:
        foo()
    except RuntimeError:
        print("RuntimeError")
    global finished

            

Reported by Pylint.

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

Line: 17 Column: 5

                      foo()
    except RuntimeError:
        print("RuntimeError")
    global finished
    finished = True


finished = False


            

Reported by Pylint.

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

Line: 21 Column: 1

                  finished = True


finished = False

_thread.start_new_thread(thread_entry, ())

# busy wait for thread to finish
while not finished:

            

Reported by Pylint.