The following issues were found

tests/basics/seq_unpack.py
6 issues
Possible unbalanced tuple unpacking with sequence (1, 2): left side has 3 label(s), right side has 2 value(s)
Error

Line: 25 Column: 5

              print(a, b, c)

try:
    a, b, c = (1, 2)
except ValueError:
    print("ValueError")
try:
    a, b, c = [1, 2, 3, 4]
except ValueError:

            

Reported by Pylint.

Possible unbalanced tuple unpacking with sequence [1, 2, 3, 4]: left side has 3 label(s), right side has 4 value(s)
Error

Line: 29 Column: 5

              except ValueError:
    print("ValueError")
try:
    a, b, c = [1, 2, 3, 4]
except ValueError:
    print("ValueError")

# Generic iterable object
a, b, c = range(3)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Basics
a, b = 1, 2
print(a, b)
a, b = (1, 2)
print(a, b)
(a, b) = 1, 2
print(a, b)
(a, b) = (1, 2)
print(a, b)

            

Reported by Pylint.

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

Line: 18 Column: 1

              print(a, b)

# optimised 3-way swap
a = 1
b = 2
c = 3
a, b, c = b, c, a
print(a, b, c)


            

Reported by Pylint.

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

Line: 19 Column: 1

              
# optimised 3-way swap
a = 1
b = 2
c = 3
a, b, c = b, c, a
print(a, b, c)

try:

            

Reported by Pylint.

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

Line: 20 Column: 1

              # optimised 3-way swap
a = 1
b = 2
c = 3
a, b, c = b, c, a
print(a, b, c)

try:
    a, b, c = (1, 2)

            

Reported by Pylint.

tests/basics/self_type_check.py
6 issues
Statement seems to have no effect
Error

Line: 3 Column: 1

              # make sure type of first arg (self) to a builtin method is checked

list.append

try:
    list.append()
except TypeError as e:
    print("TypeError")


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # make sure type of first arg (self) to a builtin method is checked

list.append

try:
    list.append()
except TypeError as e:
    print("TypeError")


            

Reported by Pylint.

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

Line: 7 Column: 1

              
try:
    list.append()
except TypeError as e:
    print("TypeError")

try:
    list.append(1)
except TypeError as e:

            

Reported by Pylint.

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

Line: 12 Column: 1

              
try:
    list.append(1)
except TypeError as e:
    print("TypeError")

try:
    list.append(1, 2)
except TypeError as e:

            

Reported by Pylint.

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

Line: 17 Column: 1

              
try:
    list.append(1, 2)
except TypeError as e:
    print("TypeError")

l = []
list.append(l, 2)
print(l)

            

Reported by Pylint.

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

Line: 26 Column: 1

              
try:
    getattr(list, "append")(1, 2)
except TypeError as e:
    print("TypeError")

l = []
getattr(list, "append")(l, 2)
print(l)

            

Reported by Pylint.

tests/basics/op_error_intbig.py
6 issues
Value '1' doesn't support membership test
Error

Line: 14 Column: 18

              
# object with buffer protocol needed on rhs
try:
    (1 << 70) in 1
except TypeError:
    print('TypeError')

            

Reported by Pylint.

Use of exec
Error

Line: 5 Column: 9

              
def test_exc(code, exc):
    try:
        exec(code)
        print("no exception")
    except exc:
        print("right exception")
    except:
        print("wrong exception")

            

Reported by Pylint.

Use of exec detected.
Security

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

              
def test_exc(code, exc):
    try:
        exec(code)
        print("no exception")
    except exc:
        print("right exception")
    except:
        print("wrong exception")

            

Reported by Bandit.

No exception type(s) specified
Error

Line: 9 Column: 5

                      print("no exception")
    except exc:
        print("right exception")
    except:
        print("wrong exception")

# object with buffer protocol needed on rhs
try:
    (1 << 70) in 1

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test errors from bad operations (unary, binary, etc)

def test_exc(code, exc):
    try:
        exec(code)
        print("no exception")
    except exc:
        print("right exception")
    except:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # test errors from bad operations (unary, binary, etc)

def test_exc(code, exc):
    try:
        exec(code)
        print("no exception")
    except exc:
        print("right exception")
    except:

            

Reported by Pylint.

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

Line: 8 Column: 5

                  print(pow(3, 4, 7))
except NotImplementedError:
    print("SKIP")
    raise SystemExit

print(pow(555557, 1000002, 1000003))

# Tests for 3 arg pow with large values


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test builtin pow() with integral values
# 3 arg version

try:
    print(pow(3, 4, 7))
except NotImplementedError:
    print("SKIP")
    raise SystemExit


            

Reported by Pylint.

Line too long (281/100)
Error

Line: 15 Column: 1

              # Tests for 3 arg pow with large values

# This value happens to be prime
x = 0xd48a1e2a099b1395895527112937a391d02d4a208bce5d74b281cf35a57362502726f79a632f063a83c0eba66196712d963aa7279ab8a504110a668c0fc38a7983c51e6ee7a85cae87097686ccdc359ee4bbf2c583bce524e3f7836bded1c771a4efcb25c09460a862fc98e18f7303df46aaeb34da46b0c4d61d5cd78350f3edb60e6bc4befa712a849
y = 0x3accf60bb1a5365e4250d1588eb0fe6cd81ad495e9063f90880229f2a625e98c59387238670936afb2cafc5b79448e4414d6cd5e9901aa845aa122db58ddd7b9f2b17414600a18c47494ed1f3d49d005a5

print(hex(pow(2, 200, x))) # Should not overflow, just 1 << 200
print(hex(pow(2, x-1, x))) # Should be 1, since x is prime
print(hex(pow(y, x-1, x))) # Should be 1, since x is prime

            

Reported by Pylint.

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

Line: 15 Column: 1

              # Tests for 3 arg pow with large values

# This value happens to be prime
x = 0xd48a1e2a099b1395895527112937a391d02d4a208bce5d74b281cf35a57362502726f79a632f063a83c0eba66196712d963aa7279ab8a504110a668c0fc38a7983c51e6ee7a85cae87097686ccdc359ee4bbf2c583bce524e3f7836bded1c771a4efcb25c09460a862fc98e18f7303df46aaeb34da46b0c4d61d5cd78350f3edb60e6bc4befa712a849
y = 0x3accf60bb1a5365e4250d1588eb0fe6cd81ad495e9063f90880229f2a625e98c59387238670936afb2cafc5b79448e4414d6cd5e9901aa845aa122db58ddd7b9f2b17414600a18c47494ed1f3d49d005a5

print(hex(pow(2, 200, x))) # Should not overflow, just 1 << 200
print(hex(pow(2, x-1, x))) # Should be 1, since x is prime
print(hex(pow(y, x-1, x))) # Should be 1, since x is prime

            

Reported by Pylint.

Line too long (168/100)
Error

Line: 16 Column: 1

              
# This value happens to be prime
x = 0xd48a1e2a099b1395895527112937a391d02d4a208bce5d74b281cf35a57362502726f79a632f063a83c0eba66196712d963aa7279ab8a504110a668c0fc38a7983c51e6ee7a85cae87097686ccdc359ee4bbf2c583bce524e3f7836bded1c771a4efcb25c09460a862fc98e18f7303df46aaeb34da46b0c4d61d5cd78350f3edb60e6bc4befa712a849
y = 0x3accf60bb1a5365e4250d1588eb0fe6cd81ad495e9063f90880229f2a625e98c59387238670936afb2cafc5b79448e4414d6cd5e9901aa845aa122db58ddd7b9f2b17414600a18c47494ed1f3d49d005a5

print(hex(pow(2, 200, x))) # Should not overflow, just 1 << 200
print(hex(pow(2, x-1, x))) # Should be 1, since x is prime
print(hex(pow(y, x-1, x))) # Should be 1, since x is prime
print(hex(pow(y, y-1, x))) # Should be a 'big value'

            

Reported by Pylint.

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

Line: 16 Column: 1

              
# This value happens to be prime
x = 0xd48a1e2a099b1395895527112937a391d02d4a208bce5d74b281cf35a57362502726f79a632f063a83c0eba66196712d963aa7279ab8a504110a668c0fc38a7983c51e6ee7a85cae87097686ccdc359ee4bbf2c583bce524e3f7836bded1c771a4efcb25c09460a862fc98e18f7303df46aaeb34da46b0c4d61d5cd78350f3edb60e6bc4befa712a849
y = 0x3accf60bb1a5365e4250d1588eb0fe6cd81ad495e9063f90880229f2a625e98c59387238670936afb2cafc5b79448e4414d6cd5e9901aa845aa122db58ddd7b9f2b17414600a18c47494ed1f3d49d005a5

print(hex(pow(2, 200, x))) # Should not overflow, just 1 << 200
print(hex(pow(2, x-1, x))) # Should be 1, since x is prime
print(hex(pow(y, x-1, x))) # Should be 1, since x is prime
print(hex(pow(y, y-1, x))) # Should be a 'big value'

            

Reported by Pylint.

tests/micropython/viper_error.py
6 issues
Undefined variable 'ViperTypeError'
Error

Line: 7 Column: 26

              def test(code):
    try:
        exec(code)
    except (SyntaxError, ViperTypeError, NotImplementedError) as e:
        print(repr(e))


# viper: annotations must be identifiers
test("@micropython.viper\ndef f(a:1): pass")

            

Reported by Pylint.

Use of exec
Error

Line: 6 Column: 9

              
def test(code):
    try:
        exec(code)
    except (SyntaxError, ViperTypeError, NotImplementedError) as e:
        print(repr(e))


# viper: annotations must be identifiers

            

Reported by Pylint.

Use of exec detected.
Security

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

              
def test(code):
    try:
        exec(code)
    except (SyntaxError, ViperTypeError, NotImplementedError) as e:
        print(repr(e))


# viper: annotations must be identifiers

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              # test syntax and type errors specific to viper code generation


def test(code):
    try:
        exec(code)
    except (SyntaxError, ViperTypeError, NotImplementedError) as e:
        print(repr(e))


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              # test syntax and type errors specific to viper code generation


def test(code):
    try:
        exec(code)
    except (SyntaxError, ViperTypeError, NotImplementedError) as e:
        print(repr(e))


            

Reported by Pylint.

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

Line: 7 Column: 5

              def test(code):
    try:
        exec(code)
    except (SyntaxError, ViperTypeError, NotImplementedError) as e:
        print(repr(e))


# viper: annotations must be identifiers
test("@micropython.viper\ndef f(a:1): pass")

            

Reported by Pylint.

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

Line: 7 Column: 5

                  next(iter([]), 42)
except TypeError:  # 2-argument version not supported
    print('SKIP')
    raise SystemExit

print(next(iter([]), 42))
print(next(iter(range(0)), 42))
print(next((x for x in [0] if x == 1), 43))


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test next(iter, default)

try:
    next(iter([]), 42)
except TypeError:  # 2-argument version not supported
    print('SKIP')
    raise SystemExit

print(next(iter([]), 42))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              print(next(iter(range(0)), 42))
print(next((x for x in [0] if x == 1), 43))

def gen():
    yield 1
    yield 2

g = gen()
print(next(g, 42))

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 22 Column: 1

              print(next(g, 43))
print(next(g, 44))

class Gen:
    def __init__(self):
        self.b = False

    def __next__(self):
        if self.b:

            

Reported by Pylint.

Missing class docstring
Error

Line: 22 Column: 1

              print(next(g, 43))
print(next(g, 44))

class Gen:
    def __init__(self):
        self.b = False

    def __next__(self):
        if self.b:

            

Reported by Pylint.

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

Line: 24 Column: 9

              
class Gen:
    def __init__(self):
        self.b = False

    def __next__(self):
        if self.b:
            raise StopIteration
        self.b = True

            

Reported by Pylint.

tests/micropython/viper_binop_comp.py
6 issues
Undefined variable 'micropython'
Error

Line: 2 Column: 2

              # test comparison operators
@micropython.viper
def f(x: int, y: int):
    if x < y:
        print(x, "<", y)
    if x > y:
        print(x, ">", y)
    if x == y:
        print(x, "==", y)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test comparison operators
@micropython.viper
def f(x: int, y: int):
    if x < y:
        print(x, "<", y)
    if x > y:
        print(x, ">", y)
    if x == y:
        print(x, "==", y)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # test comparison operators
@micropython.viper
def f(x: int, y: int):
    if x < y:
        print(x, "<", y)
    if x > y:
        print(x, ">", y)
    if x == y:
        print(x, "==", y)

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test comparison operators
@micropython.viper
def f(x: int, y: int):
    if x < y:
        print(x, "<", y)
    if x > y:
        print(x, ">", y)
    if x == y:
        print(x, "==", y)

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test comparison operators
@micropython.viper
def f(x: int, y: int):
    if x < y:
        print(x, "<", y)
    if x > y:
        print(x, ">", y)
    if x == y:
        print(x, "==", y)

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test comparison operators
@micropython.viper
def f(x: int, y: int):
    if x < y:
        print(x, "<", y)
    if x > y:
        print(x, ">", y)
    if x == y:
        print(x, "==", y)

            

Reported by Pylint.

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

Line: 11 Column: 5

                  sys.getsizeof
except AttributeError:
    print('SKIP')
    raise SystemExit

print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)

class A:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test sys.getsizeof() function

try:
    import usys as sys
except ImportError:
    import sys
try:
    sys.getsizeof
except AttributeError:

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 16 Column: 1

              print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)

class A:
    pass
print(sys.getsizeof(A()) > 0)

# Only test deque if we have it
try:

            

Reported by Pylint.

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

Line: 16 Column: 1

              print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)

class A:
    pass
print(sys.getsizeof(A()) > 0)

# Only test deque if we have it
try:

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)

class A:
    pass
print(sys.getsizeof(A()) > 0)

# Only test deque if we have it
try:

            

Reported by Pylint.

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

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

              # Only test deque if we have it
try:
    from ucollections import deque
    assert sys.getsizeof(deque((), 1)) > 0
except ImportError:
    pass

            

Reported by Bandit.

tests/micropython/viper_binop_multi_comp.py
6 issues
Undefined variable 'micropython'
Error

Line: 2 Column: 2

              # test multi comparison operators
@micropython.viper
def f(x: int, y: int):
    if 0 < x < y:
        print(x, "<", y)
    if 3 > x > y:
        print(x, ">", y)
    if 1 == x == y:
        print(x, "==", y)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test multi comparison operators
@micropython.viper
def f(x: int, y: int):
    if 0 < x < y:
        print(x, "<", y)
    if 3 > x > y:
        print(x, ">", y)
    if 1 == x == y:
        print(x, "==", y)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # test multi comparison operators
@micropython.viper
def f(x: int, y: int):
    if 0 < x < y:
        print(x, "<", y)
    if 3 > x > y:
        print(x, ">", y)
    if 1 == x == y:
        print(x, "==", y)

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test multi comparison operators
@micropython.viper
def f(x: int, y: int):
    if 0 < x < y:
        print(x, "<", y)
    if 3 > x > y:
        print(x, ">", y)
    if 1 == x == y:
        print(x, "==", y)

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test multi comparison operators
@micropython.viper
def f(x: int, y: int):
    if 0 < x < y:
        print(x, "<", y)
    if 3 > x > y:
        print(x, ">", y)
    if 1 == x == y:
        print(x, "==", y)

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test multi comparison operators
@micropython.viper
def f(x: int, y: int):
    if 0 < x < y:
        print(x, "<", y)
    if 3 > x > y:
        print(x, ">", y)
    if 1 == x == y:
        print(x, "==", y)

            

Reported by Pylint.

tests/pyb/modtime.py
6 issues
Redefining built-in 'tuple'
Error

Line: 28 Column: 17

                                      "mktime failed for %d-%02d-%02d got %d expected %d"
                        % (year, month, day, secs, seconds)
                    )
                tuple = time.localtime(seconds)
                secs = time.mktime(tuple)
                if secs != seconds:
                    print(
                        "localtime failed for %d-%02d-%02d got %d expected %d"
                        % (year, month, day, secs, seconds)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import time

DAYS_PER_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]


def is_leap(year):
    return (year % 4) == 0



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

              DAYS_PER_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]


def is_leap(year):
    return (year % 4) == 0


def test():
    seconds = 0

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

                  return (year % 4) == 0


def test():
    seconds = 0
    wday = 5  # Jan 1, 2000 was a Saturday
    for year in range(2000, 2034):
        print("Testing %d" % year)
        yday = 1

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 53 Column: 1

                              wday = (wday + 1) % 7


def spot_test(seconds, expected_time):
    actual_time = time.localtime(seconds)
    for i in range(len(actual_time)):
        if actual_time[i] != expected_time[i]:
            print(
                "time.localtime(", seconds, ") returned", actual_time, "expecting", expected_time

            

Reported by Pylint.

Consider using enumerate instead of iterating with range and len
Error

Line: 55 Column: 5

              
def spot_test(seconds, expected_time):
    actual_time = time.localtime(seconds)
    for i in range(len(actual_time)):
        if actual_time[i] != expected_time[i]:
            print(
                "time.localtime(", seconds, ") returned", actual_time, "expecting", expected_time
            )
            return

            

Reported by Pylint.