The following issues were found

tests/micropython/viper_subscr.py
9 issues
Undefined variable 'micropython'
Error

Line: 4 Column: 2

              # test standard Python subscr using viper types


@micropython.viper
def get(dest, i: int):
    i += 1
    return dest[i]



            

Reported by Pylint.

Undefined variable 'micropython'
Error

Line: 10 Column: 2

                  return dest[i]


@micropython.viper
def set(dest, i: int, val: int):
    i += 1
    dest[i] = val + 1



            

Reported by Pylint.

Redefining name 'i' from outer scope (line 18)
Error

Line: 5 Column: 15

              

@micropython.viper
def get(dest, i: int):
    i += 1
    return dest[i]


@micropython.viper

            

Reported by Pylint.

Redefining name 'i' from outer scope (line 18)
Error

Line: 11 Column: 15

              

@micropython.viper
def set(dest, i: int, val: int):
    i += 1
    dest[i] = val + 1


ar = [i for i in range(3)]

            

Reported by Pylint.

Redefining built-in 'set'
Error

Line: 11 Column: 1

              

@micropython.viper
def set(dest, i: int, val: int):
    i += 1
    dest[i] = val + 1


ar = [i for i in range(3)]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test standard Python subscr using viper types


@micropython.viper
def get(dest, i: int):
    i += 1
    return dest[i]



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              

@micropython.viper
def get(dest, i: int):
    i += 1
    return dest[i]


@micropython.viper

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

              

@micropython.viper
def set(dest, i: int, val: int):
    i += 1
    dest[i] = val + 1


ar = [i for i in range(3)]

            

Reported by Pylint.

Unnecessary use of a comprehension
Error

Line: 16 Column: 1

                  dest[i] = val + 1


ar = [i for i in range(3)]

for i in range(len(ar)):
    set(ar, i - 1, i)
print(ar)


            

Reported by Pylint.

tests/basics/subclass_native5.py
9 issues
Missing module docstring
Error

Line: 1 Column: 1

              # Subclass from 2 bases explicitly subclasses from object

class Base1(object):
    pass

class Base2(object):
    pass

class Sub(Base1, Base2):

            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              # Subclass from 2 bases explicitly subclasses from object

class Base1(object):
    pass

class Base2(object):
    pass

class Sub(Base1, Base2):

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 3 Column: 1

              # Subclass from 2 bases explicitly subclasses from object

class Base1(object):
    pass

class Base2(object):
    pass

class Sub(Base1, Base2):

            

Reported by Pylint.

Class 'Base1' inherits from object, can be safely removed from bases in python3
Error

Line: 3 Column: 1

              # Subclass from 2 bases explicitly subclasses from object

class Base1(object):
    pass

class Base2(object):
    pass

class Sub(Base1, Base2):

            

Reported by Pylint.

Class 'Base2' inherits from object, can be safely removed from bases in python3
Error

Line: 6 Column: 1

              class Base1(object):
    pass

class Base2(object):
    pass

class Sub(Base1, Base2):
    pass


            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              class Base1(object):
    pass

class Base2(object):
    pass

class Sub(Base1, Base2):
    pass


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 6 Column: 1

              class Base1(object):
    pass

class Base2(object):
    pass

class Sub(Base1, Base2):
    pass


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 9 Column: 1

              class Base2(object):
    pass

class Sub(Base1, Base2):
    pass

o = Sub()

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              class Base2(object):
    pass

class Sub(Base1, Base2):
    pass

o = Sub()

            

Reported by Pylint.

examples/hwapi/hwconfig_console.py
9 issues
Redefining built-in 'id'
Error

Line: 4 Column: 24

              # This is hwconfig for "emulation" for cases when there's no real hardware.
# It just prints information to console.
class LEDClass:
    def __init__(self, id):
        self.id = "LED(%d):" % id

    def value(self, v):
        print(self.id, v)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # This is hwconfig for "emulation" for cases when there's no real hardware.
# It just prints information to console.
class LEDClass:
    def __init__(self, id):
        self.id = "LED(%d):" % id

    def value(self, v):
        print(self.id, v)


            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              # This is hwconfig for "emulation" for cases when there's no real hardware.
# It just prints information to console.
class LEDClass:
    def __init__(self, id):
        self.id = "LED(%d):" % id

    def value(self, v):
        print(self.id, v)


            

Reported by Pylint.

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

Line: 5 Column: 9

              # It just prints information to console.
class LEDClass:
    def __init__(self, id):
        self.id = "LED(%d):" % id

    def value(self, v):
        print(self.id, v)

    def on(self):

            

Reported by Pylint.

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

Line: 7 Column: 5

                  def __init__(self, id):
        self.id = "LED(%d):" % id

    def value(self, v):
        print(self.id, v)

    def on(self):
        self.value(1)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 5

                  def __init__(self, id):
        self.id = "LED(%d):" % id

    def value(self, v):
        print(self.id, v)

    def on(self):
        self.value(1)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 5

                  def value(self, v):
        print(self.id, v)

    def on(self):
        self.value(1)

    def off(self):
        self.value(0)


            

Reported by Pylint.

Method name "on" doesn't conform to snake_case naming style
Error

Line: 10 Column: 5

                  def value(self, v):
        print(self.id, v)

    def on(self):
        self.value(1)

    def off(self):
        self.value(0)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

                  def on(self):
        self.value(1)

    def off(self):
        self.value(0)


LED = LEDClass(1)
LED2 = LEDClass(12)

            

Reported by Pylint.

tests/perf_bench/viper_call1b.py
9 issues
Undefined variable 'micropython'
Error

Line: 1 Column: 2

              @micropython.viper
def f1b(x) -> int:
    return int(x)


@micropython.native
def call(r):
    f = f1b
    for _ in r:

            

Reported by Pylint.

Undefined variable 'micropython'
Error

Line: 6 Column: 2

                  return int(x)


@micropython.native
def call(r):
    f = f1b
    for _ in r:
        f(1)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              @micropython.viper
def f1b(x) -> int:
    return int(x)


@micropython.native
def call(r):
    f = f1b
    for _ in r:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 2 Column: 1

              @micropython.viper
def f1b(x) -> int:
    return int(x)


@micropython.native
def call(r):
    f = f1b
    for _ in r:

            

Reported by Pylint.

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

Line: 2 Column: 1

              @micropython.viper
def f1b(x) -> int:
    return int(x)


@micropython.native
def call(r):
    f = f1b
    for _ in r:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              

@micropython.native
def call(r):
    f = f1b
    for _ in r:
        f(1)



            

Reported by Pylint.

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

Line: 7 Column: 1

              

@micropython.native
def call(r):
    f = f1b
    for _ in r:
        f(1)



            

Reported by Pylint.

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

Line: 8 Column: 5

              
@micropython.native
def call(r):
    f = f1b
    for _ in r:
        f(1)


bm_params = {

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 1

              }


def bm_setup(params):
    return lambda: call(range(params[0])), lambda: (params[0] // 1000, None)

            

Reported by Pylint.

examples/unix/ffi_example.py
9 issues
Unable to import 'ffi'
Error

Line: 1 Column: 1

              import ffi
import uctypes

libc = ffi.open("libc.so.6")
print("libc:", libc)
print()

# Declare few functions
perror = libc.func("v", "perror", "s")

            

Reported by Pylint.

Unable to import 'uctypes'
Error

Line: 2 Column: 1

              import ffi
import uctypes

libc = ffi.open("libc.so.6")
print("libc:", libc)
print()

# Declare few functions
perror = libc.func("v", "perror", "s")

            

Reported by Pylint.

Redefining built-in 'open'
Error

Line: 11 Column: 1

              # Declare few functions
perror = libc.func("v", "perror", "s")
time = libc.func("i", "time", "p")
open = libc.func("i", "open", "si")
qsort = libc.func("v", "qsort", "piiC")
# And one variable
errno = libc.var("i", "errno")

print("time:", time)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import ffi
import uctypes

libc = ffi.open("libc.so.6")
print("libc:", libc)
print()

# Declare few functions
perror = libc.func("v", "perror", "s")

            

Reported by Pylint.

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

Line: 28 Column: 1

              print()


def cmp(pa, pb):
    a = uctypes.bytearray_at(pa, 1)
    b = uctypes.bytearray_at(pb, 1)
    print("cmp:", a, b)
    return a[0] - b[0]


            

Reported by Pylint.

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

Line: 28 Column: 1

              print()


def cmp(pa, pb):
    a = uctypes.bytearray_at(pa, 1)
    b = uctypes.bytearray_at(pb, 1)
    print("cmp:", a, b)
    return a[0] - b[0]


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

              print()


def cmp(pa, pb):
    a = uctypes.bytearray_at(pa, 1)
    b = uctypes.bytearray_at(pb, 1)
    print("cmp:", a, b)
    return a[0] - b[0]


            

Reported by Pylint.

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

Line: 29 Column: 5

              

def cmp(pa, pb):
    a = uctypes.bytearray_at(pa, 1)
    b = uctypes.bytearray_at(pb, 1)
    print("cmp:", a, b)
    return a[0] - b[0]



            

Reported by Pylint.

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

Line: 30 Column: 5

              
def cmp(pa, pb):
    a = uctypes.bytearray_at(pa, 1)
    b = uctypes.bytearray_at(pb, 1)
    print("cmp:", a, b)
    return a[0] - b[0]


cmp_cb = ffi.callback("i", cmp, "PP")

            

Reported by Pylint.

examples/rp2/pwm_fade.py
8 issues
Unable to import 'machine'
Error

Line: 4 Column: 1

              # Example using PWM to fade an LED.

import time
from machine import Pin, PWM


# Construct PWM object, with LED on Pin(25).
pwm = PWM(Pin(25))


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Example using PWM to fade an LED.

import time
from machine import Pin, PWM


# Construct PWM object, with LED on Pin(25).
pwm = PWM(Pin(25))


            

Reported by Pylint.

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

Line: 14 Column: 1

              pwm.freq(1000)

# Fade the LED in and out a few times.
duty = 0
direction = 1
for _ in range(8 * 256):
    duty += direction
    if duty > 255:
        duty = 255

            

Reported by Pylint.

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

Line: 15 Column: 1

              
# Fade the LED in and out a few times.
duty = 0
direction = 1
for _ in range(8 * 256):
    duty += direction
    if duty > 255:
        duty = 255
        direction = -1

            

Reported by Pylint.

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

Line: 19 Column: 9

              for _ in range(8 * 256):
    duty += direction
    if duty > 255:
        duty = 255
        direction = -1
    elif duty < 0:
        duty = 0
        direction = 1
    pwm.duty_u16(duty * duty)

            

Reported by Pylint.

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

Line: 20 Column: 9

                  duty += direction
    if duty > 255:
        duty = 255
        direction = -1
    elif duty < 0:
        duty = 0
        direction = 1
    pwm.duty_u16(duty * duty)
    time.sleep(0.001)

            

Reported by Pylint.

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

Line: 22 Column: 9

                      duty = 255
        direction = -1
    elif duty < 0:
        duty = 0
        direction = 1
    pwm.duty_u16(duty * duty)
    time.sleep(0.001)

            

Reported by Pylint.

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

Line: 23 Column: 9

                      direction = -1
    elif duty < 0:
        duty = 0
        direction = 1
    pwm.duty_u16(duty * duty)
    time.sleep(0.001)

            

Reported by Pylint.

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

Line: 6 Column: 5

                  delattr
except:
    print("SKIP")
    raise SystemExit

class A: pass
a = A()
a.x = 1
print(a.x)

            

Reported by Pylint.

Attribute 'x' defined outside __init__
Error

Line: 10 Column: 1

              
class A: pass
a = A()
a.x = 1
print(a.x)

delattr(a, 'x')

try:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test builtin delattr
try:
    delattr
except:
    print("SKIP")
    raise SystemExit

class A: pass
a = A()

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 8 Column: 10

                  print("SKIP")
    raise SystemExit

class A: pass
a = A()
a.x = 1
print(a.x)

delattr(a, 'x')

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 8 Column: 1

                  print("SKIP")
    raise SystemExit

class A: pass
a = A()
a.x = 1
print(a.x)

delattr(a, 'x')

            

Reported by Pylint.

Missing class docstring
Error

Line: 8 Column: 1

                  print("SKIP")
    raise SystemExit

class A: pass
a = A()
a.x = 1
print(a.x)

delattr(a, 'x')

            

Reported by Pylint.

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

Line: 8 Column: 1

                  print("SKIP")
    raise SystemExit

class A: pass
a = A()
a.x = 1
print(a.x)

delattr(a, 'x')

            

Reported by Pylint.

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

Line: 10 Column: 1

              
class A: pass
a = A()
a.x = 1
print(a.x)

delattr(a, 'x')

try:

            

Reported by Pylint.

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/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.