The following issues were found

tests/basics/try_finally_break.py
30 issues
function already defined line 4
Error

Line: 18 Column: 1

              f()

# where the finally swallows an exception
def f():
    lst = [1, 2, 3]
    for x in lst:
        print('a', x)
        try:
            raise Exception

            

Reported by Pylint.

function already defined line 4
Error

Line: 31 Column: 1

              f()

# basic nested finally with break in inner finally
def f():
    for i in range(2):
        print('iter', i)
        try:
            raise TypeError
        finally:

            

Reported by Pylint.

function already defined line 4
Error

Line: 45 Column: 1

              print(f())

# similar to above but more nesting
def f():
    for i in range(2):
        try:
            raise ValueError
        finally:
            print(1)

            

Reported by Pylint.

function already defined line 4
Error

Line: 62 Column: 1

              print(f())

# lots of nesting
def f():
    for i in range(2):
        try:
            raise ValueError
        finally:
            print(1)

            

Reported by Pylint.

function already defined line 4
Error

Line: 79 Column: 1

              print(f())

# basic case combined with try-else
def f(arg):
    for _ in range(2):
        print(1)
        try:
            if arg == 1:
                raise ValueError

            

Reported by Pylint.

break statement in finally block may swallow exception
Error

Line: 11 Column: 13

                          pass
        finally:
            print(2)
            break
            print(3)
        print(4)
    print(5)
f()


            

Reported by Pylint.

Unreachable code
Error

Line: 12 Column: 13

                      finally:
            print(2)
            break
            print(3)
        print(4)
    print(5)
f()

# where the finally swallows an exception

            

Reported by Pylint.

break statement in finally block may swallow exception
Error

Line: 26 Column: 13

                          raise Exception
        finally:
            print(1)
            break
        print('b', x)
f()

# basic nested finally with break in inner finally
def f():

            

Reported by Pylint.

break statement in finally block may swallow exception
Error

Line: 41 Column: 17

                          try:
                raise ValueError
            finally:
                break
print(f())

# similar to above but more nesting
def f():
    for i in range(2):

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 46 Column: 9

              
# similar to above but more nesting
def f():
    for i in range(2):
        try:
            raise ValueError
        finally:
            print(1)
            try:

            

Reported by Pylint.

tests/inlineasm/asmargs.py
30 issues
Undefined variable 'micropython'
Error

Line: 4 Column: 2

              # test passing arguments


@micropython.asm_thumb
def arg0():
    mov(r0, 1)


print(arg0())

            

Reported by Pylint.

Undefined variable 'r0'
Error

Line: 6 Column: 9

              
@micropython.asm_thumb
def arg0():
    mov(r0, 1)


print(arg0())



            

Reported by Pylint.

Undefined variable 'mov'
Error

Line: 6 Column: 5

              
@micropython.asm_thumb
def arg0():
    mov(r0, 1)


print(arg0())



            

Reported by Pylint.

Undefined variable 'micropython'
Error

Line: 12 Column: 2

              print(arg0())


@micropython.asm_thumb
def arg1(r0):
    add(r0, r0, 1)


print(arg1(1))

            

Reported by Pylint.

Undefined variable 'add'
Error

Line: 14 Column: 5

              
@micropython.asm_thumb
def arg1(r0):
    add(r0, r0, 1)


print(arg1(1))



            

Reported by Pylint.

Undefined variable 'micropython'
Error

Line: 20 Column: 2

              print(arg1(1))


@micropython.asm_thumb
def arg2(r0, r1):
    add(r0, r0, r1)


print(arg2(1, 2))

            

Reported by Pylint.

Undefined variable 'add'
Error

Line: 22 Column: 5

              
@micropython.asm_thumb
def arg2(r0, r1):
    add(r0, r0, r1)


print(arg2(1, 2))



            

Reported by Pylint.

Undefined variable 'micropython'
Error

Line: 28 Column: 2

              print(arg2(1, 2))


@micropython.asm_thumb
def arg3(r0, r1, r2):
    add(r0, r0, r1)
    add(r0, r0, r2)



            

Reported by Pylint.

Undefined variable 'add'
Error

Line: 30 Column: 5

              
@micropython.asm_thumb
def arg3(r0, r1, r2):
    add(r0, r0, r1)
    add(r0, r0, r2)


print(arg3(1, 2, 3))


            

Reported by Pylint.

Undefined variable 'add'
Error

Line: 31 Column: 5

              @micropython.asm_thumb
def arg3(r0, r1, r2):
    add(r0, r0, r1)
    add(r0, r0, r2)


print(arg3(1, 2, 3))



            

Reported by Pylint.

tests/basics/builtin_override.py
30 issues
Unable to import 'a'
Error

Line: 31 Column: 1

                  return M
builtins.__import__ = custom_import
__import__('A', None, None, None, 0)
import a
import a.b
from a import a
from a.b import a, b
from .a import a
from ..a import a, b

            

Reported by Pylint.

Unable to import 'a.b'
Error

Line: 32 Column: 1

              builtins.__import__ = custom_import
__import__('A', None, None, None, 0)
import a
import a.b
from a import a
from a.b import a, b
from .a import a
from ..a import a, b

            

Reported by Pylint.

Unable to import 'a'
Error

Line: 33 Column: 1

              __import__('A', None, None, None, 0)
import a
import a.b
from a import a
from a.b import a, b
from .a import a
from ..a import a, b

            

Reported by Pylint.

Unable to import 'a.b'
Error

Line: 34 Column: 1

              import a
import a.b
from a import a
from a.b import a, b
from .a import a
from ..a import a, b

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 35 Column: 1

              import a.b
from a import a
from a.b import a, b
from .a import a
from ..a import a, b

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 36 Column: 1

              from a import a
from a.b import a, b
from .a import a
from ..a import a, b

            

Reported by Pylint.

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

Line: 10 Column: 5

                  builtins.abs = lambda x: x + 1
except AttributeError:
    print("SKIP")
    raise SystemExit

print(abs(1))

# __build_class__ is handled in a special way
orig_build_class = __build_class__

            

Reported by Pylint.

Unused argument 'locals'
Error

Line: 23 Column: 34

              builtins.__build_class__ = orig_build_class

# __import__ is handled in a special way
def custom_import(name, globals, locals, fromlist, level):
    print('import', name, fromlist, level)
    class M:
        a = 1
        b = 2
    return M

            

Reported by Pylint.

Redefining built-in 'globals'
Error

Line: 23 Column: 25

              builtins.__build_class__ = orig_build_class

# __import__ is handled in a special way
def custom_import(name, globals, locals, fromlist, level):
    print('import', name, fromlist, level)
    class M:
        a = 1
        b = 2
    return M

            

Reported by Pylint.

Redefining built-in 'locals'
Error

Line: 23 Column: 34

              builtins.__build_class__ = orig_build_class

# __import__ is handled in a special way
def custom_import(name, globals, locals, fromlist, level):
    print('import', name, fromlist, level)
    class M:
        a = 1
        b = 2
    return M

            

Reported by Pylint.

tests/micropython/heapalloc.py
30 issues
Unable to import 'micropython'
Error

Line: 3 Column: 1

              # check that we can do certain things without allocating heap memory

import micropython

# Check for stackless build, which can't call functions without
# allocating a frame on heap.
try:

    def stackless():

            

Reported by Pylint.

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

Line: 17 Column: 5

                  micropython.heap_unlock()
except RuntimeError:
    print("SKIP")
    raise SystemExit


def f1(a):
    print(a)


            

Reported by Pylint.

Using global for 'global_exc' but no assignment is done
Error

Line: 40 Column: 5

              

def test():
    global global_var, global_exc
    global_var = 2  # set an existing global variable
    for i in range(2):  # for loop
        f1(i)  # function call
        f1(i * 2 + 1)  # binary operation with small ints
        f1(a=i)  # keyword arguments

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # check that we can do certain things without allocating heap memory

import micropython

# Check for stackless build, which can't call functions without
# allocating a frame on heap.
try:

    def stackless():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 5

              # allocating a frame on heap.
try:

    def stackless():
        pass

    micropython.heap_lock()
    stackless()
    micropython.heap_unlock()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

                  raise SystemExit


def f1(a):
    print(a)


def f2(a, b=2):
    print(a, b)

            

Reported by Pylint.

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

Line: 20 Column: 1

                  raise SystemExit


def f1(a):
    print(a)


def f2(a, b=2):
    print(a, b)

            

Reported by Pylint.

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

Line: 20 Column: 1

                  raise SystemExit


def f1(a):
    print(a)


def f2(a, b=2):
    print(a, b)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 1

                  print(a)


def f2(a, b=2):
    print(a, b)


def f3(a, b, c, d):
    x1 = x2 = a

            

Reported by Pylint.

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

Line: 24 Column: 1

                  print(a)


def f2(a, b=2):
    print(a, b)


def f3(a, b, c, d):
    x1 = x2 = a

            

Reported by Pylint.

extmod/webrepl/webrepl.py
30 issues
Unable to import 'uos'
Error

Line: 3 Column: 1

              # This module should be imported from REPL, not run from command line.
import socket
import uos
import network
import uwebsocket
import websocket_helper
import _webrepl

listen_s = None

            

Reported by Pylint.

Unable to import 'network'
Error

Line: 4 Column: 1

              # This module should be imported from REPL, not run from command line.
import socket
import uos
import network
import uwebsocket
import websocket_helper
import _webrepl

listen_s = None

            

Reported by Pylint.

Unable to import 'uwebsocket'
Error

Line: 5 Column: 1

              import socket
import uos
import network
import uwebsocket
import websocket_helper
import _webrepl

listen_s = None
client_s = None

            

Reported by Pylint.

Unable to import '_webrepl'
Error

Line: 7 Column: 1

              import network
import uwebsocket
import websocket_helper
import _webrepl

listen_s = None
client_s = None



            

Reported by Pylint.

Unable to import 'webrepl_cfg'
Error

Line: 66 Column: 13

                  stop()
    if password is None:
        try:
            import webrepl_cfg

            _webrepl.password(webrepl_cfg.PASS)
            setup_conn(port, accept_conn)
            print("Started webrepl in normal mode")
        except:

            

Reported by Pylint.

Using the global statement
Error

Line: 14 Column: 5

              

def setup_conn(port, accept_handler):
    global listen_s
    listen_s = socket.socket()
    listen_s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

    ai = socket.getaddrinfo("0.0.0.0", port)
    addr = ai[0][4]

            

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

                  listen_s = socket.socket()
    listen_s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

    ai = socket.getaddrinfo("0.0.0.0", port)
    addr = ai[0][4]

    listen_s.bind(addr)
    listen_s.listen(1)
    if accept_handler:

            

Reported by Bandit.

Using the global statement
Error

Line: 33 Column: 5

              

def accept_conn(listen_sock):
    global client_s
    cl, remote_addr = listen_sock.accept()
    prev = uos.dupterm(None)
    uos.dupterm(prev)
    if prev:
        print("\nConcurrent WebREPL connection from", remote_addr, "rejected")

            

Reported by Pylint.

Access to a protected member _webrepl of a client class
Error

Line: 45 Column: 10

                  client_s = cl
    websocket_helper.server_handshake(cl)
    ws = uwebsocket.websocket(cl, True)
    ws = _webrepl._webrepl(ws)
    cl.setblocking(False)
    # notify REPL on socket incoming data (ESP32/ESP8266-only)
    if hasattr(uos, "dupterm_notify"):
        cl.setsockopt(socket.SOL_SOCKET, 20, uos.dupterm_notify)
    uos.dupterm(ws)

            

Reported by Pylint.

Using the global statement
Error

Line: 54 Column: 5

              

def stop():
    global listen_s, client_s
    uos.dupterm(None)
    if client_s:
        client_s.close()
    if listen_s:
        listen_s.close()

            

Reported by Pylint.

tests/inlineasm/asmfpsqrt.py
30 issues
Undefined variable 'micropython'
Error

Line: 2 Column: 2

              # test vsqrt, vneg
@micropython.asm_thumb  # r0 = -(int)(sqrt(r0)*r1)
def sqrt_test(r0, r1):
    vmov(s1, r0)
    vcvt_f32_s32(s1, s1)
    vsqrt(s1, s1)
    vmov(s2, r1)
    vcvt_f32_s32(s2, s2)
    vmul(s0, s1, s2)

            

Reported by Pylint.

Undefined variable 'vmov'
Error

Line: 4 Column: 5

              # test vsqrt, vneg
@micropython.asm_thumb  # r0 = -(int)(sqrt(r0)*r1)
def sqrt_test(r0, r1):
    vmov(s1, r0)
    vcvt_f32_s32(s1, s1)
    vsqrt(s1, s1)
    vmov(s2, r1)
    vcvt_f32_s32(s2, s2)
    vmul(s0, s1, s2)

            

Reported by Pylint.

Undefined variable 's1'
Error

Line: 4 Column: 10

              # test vsqrt, vneg
@micropython.asm_thumb  # r0 = -(int)(sqrt(r0)*r1)
def sqrt_test(r0, r1):
    vmov(s1, r0)
    vcvt_f32_s32(s1, s1)
    vsqrt(s1, s1)
    vmov(s2, r1)
    vcvt_f32_s32(s2, s2)
    vmul(s0, s1, s2)

            

Reported by Pylint.

Undefined variable 's1'
Error

Line: 5 Column: 22

              @micropython.asm_thumb  # r0 = -(int)(sqrt(r0)*r1)
def sqrt_test(r0, r1):
    vmov(s1, r0)
    vcvt_f32_s32(s1, s1)
    vsqrt(s1, s1)
    vmov(s2, r1)
    vcvt_f32_s32(s2, s2)
    vmul(s0, s1, s2)
    vneg(s7, s0)

            

Reported by Pylint.

Undefined variable 'vcvt_f32_s32'
Error

Line: 5 Column: 5

              @micropython.asm_thumb  # r0 = -(int)(sqrt(r0)*r1)
def sqrt_test(r0, r1):
    vmov(s1, r0)
    vcvt_f32_s32(s1, s1)
    vsqrt(s1, s1)
    vmov(s2, r1)
    vcvt_f32_s32(s2, s2)
    vmul(s0, s1, s2)
    vneg(s7, s0)

            

Reported by Pylint.

Undefined variable 's1'
Error

Line: 5 Column: 18

              @micropython.asm_thumb  # r0 = -(int)(sqrt(r0)*r1)
def sqrt_test(r0, r1):
    vmov(s1, r0)
    vcvt_f32_s32(s1, s1)
    vsqrt(s1, s1)
    vmov(s2, r1)
    vcvt_f32_s32(s2, s2)
    vmul(s0, s1, s2)
    vneg(s7, s0)

            

Reported by Pylint.

Undefined variable 's1'
Error

Line: 6 Column: 11

              def sqrt_test(r0, r1):
    vmov(s1, r0)
    vcvt_f32_s32(s1, s1)
    vsqrt(s1, s1)
    vmov(s2, r1)
    vcvt_f32_s32(s2, s2)
    vmul(s0, s1, s2)
    vneg(s7, s0)
    vcvt_s32_f32(s31, s7)

            

Reported by Pylint.

Undefined variable 's1'
Error

Line: 6 Column: 15

              def sqrt_test(r0, r1):
    vmov(s1, r0)
    vcvt_f32_s32(s1, s1)
    vsqrt(s1, s1)
    vmov(s2, r1)
    vcvt_f32_s32(s2, s2)
    vmul(s0, s1, s2)
    vneg(s7, s0)
    vcvt_s32_f32(s31, s7)

            

Reported by Pylint.

Undefined variable 'vsqrt'
Error

Line: 6 Column: 5

              def sqrt_test(r0, r1):
    vmov(s1, r0)
    vcvt_f32_s32(s1, s1)
    vsqrt(s1, s1)
    vmov(s2, r1)
    vcvt_f32_s32(s2, s2)
    vmul(s0, s1, s2)
    vneg(s7, s0)
    vcvt_s32_f32(s31, s7)

            

Reported by Pylint.

Undefined variable 's2'
Error

Line: 7 Column: 10

                  vmov(s1, r0)
    vcvt_f32_s32(s1, s1)
    vsqrt(s1, s1)
    vmov(s2, r1)
    vcvt_f32_s32(s2, s2)
    vmul(s0, s1, s2)
    vneg(s7, s0)
    vcvt_s32_f32(s31, s7)
    vmov(r0, s31)

            

Reported by Pylint.

tests/net_inet/getaddrinfo.py
29 issues
Unused import sys
Error

Line: 2 Column: 5

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


def test_non_existent():
    try:
        res = socket.getaddrinfo("nonexistent.example.com", 80)

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 3 Column: 1

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


def test_non_existent():
    try:
        res = socket.getaddrinfo("nonexistent.example.com", 80)

            

Reported by Pylint.

Unused variable 'e'
Error

Line: 11 Column: 5

                  try:
        res = socket.getaddrinfo("nonexistent.example.com", 80)
        print("getaddrinfo returned", res)
    except OSError as e:
        print("getaddrinfo raised")


def test_bogus():
    try:

            

Reported by Pylint.

Unused variable 'e'
Error

Line: 19 Column: 5

                  try:
        res = socket.getaddrinfo("hey.!!$$", 80)
        print("getaddrinfo returned", res)
    except OSError as e:
        print("getaddrinfo raised")
    except Exception as e:
        print("getaddrinfo raised")  # CPython raises UnicodeError!?



            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 21 Column: 12

                      print("getaddrinfo returned", res)
    except OSError as e:
        print("getaddrinfo raised")
    except Exception as e:
        print("getaddrinfo raised")  # CPython raises UnicodeError!?


def test_ip_addr():
    try:

            

Reported by Pylint.

Unused variable 'res'
Error

Line: 27 Column: 9

              
def test_ip_addr():
    try:
        res = socket.getaddrinfo("10.10.10.10", 80)
        print("getaddrinfo returned resolutions")
    except Exception as e:
        print("getaddrinfo raised", e)



            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 29 Column: 12

                  try:
        res = socket.getaddrinfo("10.10.10.10", 80)
        print("getaddrinfo returned resolutions")
    except Exception as e:
        print("getaddrinfo raised", e)


def test_0_0_0_0():
    try:

            

Reported by Pylint.

Possible binding to all interfaces.
Security

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

              
def test_0_0_0_0():
    try:
        res = socket.getaddrinfo("0.0.0.0", 80)
        print("getaddrinfo returned resolutions")
    except Exception as e:
        print("getaddrinfo raised", e)



            

Reported by Bandit.

Unused variable 'res'
Error

Line: 35 Column: 9

              
def test_0_0_0_0():
    try:
        res = socket.getaddrinfo("0.0.0.0", 80)
        print("getaddrinfo returned resolutions")
    except Exception as e:
        print("getaddrinfo raised", e)



            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 37 Column: 12

                  try:
        res = socket.getaddrinfo("0.0.0.0", 80)
        print("getaddrinfo returned resolutions")
    except Exception as e:
        print("getaddrinfo raised", e)


def test_valid():
    try:

            

Reported by Pylint.

examples/bluetooth/ble_bonding_peripheral.py
29 issues
Unable to import 'bluetooth'
Error

Line: 8 Column: 1

              #
# Work-in-progress demo of implementing bonding and passkey auth.

import bluetooth
import random
import struct
import time
import json
import binascii

            

Reported by Pylint.

Unable to import 'micropython'
Error

Line: 16 Column: 1

              import binascii
from ble_advertising import advertising_payload

from micropython import const

_IRQ_CENTRAL_CONNECT = const(1)
_IRQ_CENTRAL_DISCONNECT = const(2)
_IRQ_GATTS_INDICATE_DONE = const(20)


            

Reported by Pylint.

Module 'time' has no 'sleep_ms' member
Error

Line: 190 Column: 9

                      temp.set_temperature(t, notify=i == 0, indicate=False)
        # Random walk the temperature.
        t += random.uniform(-0.5, 0.5)
        time.sleep_ms(1000)


if __name__ == "__main__":
    demo()

            

Reported by Pylint.

Unused variable 'value_handle'
Error

Line: 108 Column: 26

                          else:
                print("unknown action")
        elif event == _IRQ_GATTS_INDICATE_DONE:
            conn_handle, value_handle, status = data
        elif event == _IRQ_SET_SECRET:
            sec_type, key, value = data
            key = sec_type, bytes(key)
            value = bytes(value) if value else None
            print("set secret:", key, value)

            

Reported by Pylint.

Unused variable 'status'
Error

Line: 108 Column: 40

                          else:
                print("unknown action")
        elif event == _IRQ_GATTS_INDICATE_DONE:
            conn_handle, value_handle, status = data
        elif event == _IRQ_SET_SECRET:
            sec_type, key, value = data
            key = sec_type, bytes(key)
            value = bytes(value) if value else None
            print("set secret:", key, value)

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 162 Column: 9

                              entries = json.load(f)
                for sec_type, key, value in entries:
                    self._secrets[sec_type, binascii.a2b_base64(key)] = binascii.a2b_base64(value)
        except:
            print("no secrets available")

    def _save_secrets(self):
        try:
            with open("secrets.json", "w") as f:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 173 Column: 9

                                  for (sec_type, key), value in self._secrets.items()
                ]
                json.dump(json_secrets, f)
        except:
            print("failed to save secrets")


def demo():
    ble = bluetooth.BLE()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # This example demonstrates a simple temperature sensor peripheral.
#
# The sensor's local value updates every second, and it will notify
# any connected central every 10 seconds.
#
# Work-in-progress demo of implementing bonding and passkey auth.

import bluetooth
import random

            

Reported by Pylint.

standard import "import random" should be placed before "import bluetooth"
Error

Line: 9 Column: 1

              # Work-in-progress demo of implementing bonding and passkey auth.

import bluetooth
import random
import struct
import time
import json
import binascii
from ble_advertising import advertising_payload

            

Reported by Pylint.

standard import "import struct" should be placed before "import bluetooth"
Error

Line: 10 Column: 1

              
import bluetooth
import random
import struct
import time
import json
import binascii
from ble_advertising import advertising_payload


            

Reported by Pylint.

tests/basics/scope.py
29 issues
function already defined line 5
Error

Line: 13 Column: 1

              print(a)

# explicit nonlocal variable
def f():
    a = 1
    def g():
        nonlocal a
        nonlocal a, a # should be able to redefine as nonlocal
        a = 2

            

Reported by Pylint.

function already defined line 5
Error

Line: 24 Column: 1

              print(f())

# nonlocal at inner-inner level (h)
def f():
    x = 1
    def g():
        def h():
            nonlocal x
            return x

            

Reported by Pylint.

function already defined line 5
Error

Line: 35 Column: 1

              print(f()()())

# nonlocal declared at outer level (g), and referenced by inner level (h)
def f():
    x = 1
    def g():
        nonlocal x
        def h():
            return x

            

Reported by Pylint.

Using the global statement
Error

Line: 6 Column: 5

              # explicit global variable
a = 1
def f():
    global a
    global a, a # should be able to redefine as global
    a = 2
f()
print(a)


            

Reported by Pylint.

Using the global statement
Error

Line: 7 Column: 5

              a = 1
def f():
    global a
    global a, a # should be able to redefine as global
    a = 2
f()
print(a)

# explicit nonlocal variable

            

Reported by Pylint.

Redefining name 'a' from outer scope (line 4)
Error

Line: 14 Column: 5

              
# explicit nonlocal variable
def f():
    a = 1
    def g():
        nonlocal a
        nonlocal a, a # should be able to redefine as nonlocal
        a = 2
    g()

            

Reported by Pylint.

Redefining name 'a' from outer scope (line 4)
Error

Line: 18 Column: 9

                  def g():
        nonlocal a
        nonlocal a, a # should be able to redefine as nonlocal
        a = 2
    g()
    return a
print(f())

# nonlocal at inner-inner level (h)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test scoping rules

# explicit global variable
a = 1
def f():
    global a
    global a, a # should be able to redefine as global
    a = 2
f()

            

Reported by Pylint.

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

Line: 4 Column: 1

              # test scoping rules

# explicit global variable
a = 1
def f():
    global a
    global a, a # should be able to redefine as global
    a = 2
f()

            

Reported by Pylint.

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

Line: 5 Column: 1

              
# explicit global variable
a = 1
def f():
    global a
    global a, a # should be able to redefine as global
    a = 2
f()
print(a)

            

Reported by Pylint.

tests/wipy/wlan/wlan.py
29 issues
Unable to import 'network'
Error

Line: 5 Column: 1

              WLAN test for the CC3200 based boards.
"""

from network import WLAN
import os
import time
import testconfig

mch = os.uname().machine

            

Reported by Pylint.

Unable to import 'testconfig'
Error

Line: 8 Column: 1

              from network import WLAN
import os
import time
import testconfig

mch = os.uname().machine
if not "LaunchPad" in mch and not "WiPy" in mch:
    raise Exception("Board not supported!")


            

Reported by Pylint.

Module 'time' has no 'ticks_ms' member
Error

Line: 97 Column: 6

              wifi.disconnect()
print(wifi.isconnected() == False)

t0 = time.ticks_ms()
wifi.connect(testconfig.wlan_ssid, auth=testconfig.wlan_auth, timeout=0)
print(time.ticks_ms() - t0 < 500)

wifi.disconnect()
print(wifi.isconnected() == False)

            

Reported by Pylint.

Module 'time' has no 'ticks_ms' member
Error

Line: 99 Column: 7

              
t0 = time.ticks_ms()
wifi.connect(testconfig.wlan_ssid, auth=testconfig.wlan_auth, timeout=0)
print(time.ticks_ms() - t0 < 500)

wifi.disconnect()
print(wifi.isconnected() == False)

# test init again

            

Reported by Pylint.

Redefining name 'wifi' from outer scope (line 25)
Error

Line: 15 Column: 25

                  raise Exception("Board not supported!")


def wait_for_connection(wifi, timeout=10):
    while not wifi.isconnected() and timeout > 0:
        time.sleep(1)
        timeout -= 1
    if wifi.isconnected():
        print("Connected")

            

Reported by Pylint.

Possible binding to all interfaces.
Security

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

              
wifi.ifconfig(config="dhcp")
wait_for_connection(wifi)
print("0.0.0.0" not in wifi.ifconfig())
wifi.ifconfig(0, ("192.168.178.109", "255.255.255.0", "192.168.178.1", "8.8.8.8"))
wait_for_connection(wifi)
print(wifi.ifconfig(0) == ("192.168.178.109", "255.255.255.0", "192.168.178.1", "8.8.8.8"))
wait_for_connection(wifi)


            

Reported by Bandit.

No exception type(s) specified
Error

Line: 120 Column: 1

              # next ones MUST raise
try:
    wifi.init(mode=12345)
except:
    print("Exception")

try:
    wifi.init(1, mode=WLAN.AP)
except:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 125 Column: 1

              
try:
    wifi.init(1, mode=WLAN.AP)
except:
    print("Exception")

try:
    wifi.init(mode=WLAN.AP, ssid=None)
except:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 130 Column: 1

              
try:
    wifi.init(mode=WLAN.AP, ssid=None)
except:
    print("Exception")

try:
    wifi = WLAN(mode=WLAN.AP, channel=12)
except:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 135 Column: 1

              
try:
    wifi = WLAN(mode=WLAN.AP, channel=12)
except:
    print("Exception")

try:
    wifi.antenna(2)
except:

            

Reported by Pylint.