The following issues were found

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/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/internal_bench/var-6.1-instance-attr-5.py
7 issues
Unused argument 'num'
Error

Line: 13 Column: 10

                      self.num = 20000000


def test(num):
    o = Foo()
    i = 0
    while i < o.num:
        i += 1


            

Reported by Pylint.

Module name "1-instance-attr-5" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              import bench


class Foo:
    def __init__(self):
        self.num1 = 0
        self.num2 = 0
        self.num3 = 0
        self.num4 = 0

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import bench


class Foo:
    def __init__(self):
        self.num1 = 0
        self.num2 = 0
        self.num3 = 0
        self.num4 = 0

            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              import bench


class Foo:
    def __init__(self):
        self.num1 = 0
        self.num2 = 0
        self.num3 = 0
        self.num4 = 0

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 4 Column: 1

              import bench


class Foo:
    def __init__(self):
        self.num1 = 0
        self.num2 = 0
        self.num3 = 0
        self.num4 = 0

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

                      self.num = 20000000


def test(num):
    o = Foo()
    i = 0
    while i < o.num:
        i += 1


            

Reported by Pylint.

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

Line: 14 Column: 5

              

def test(num):
    o = Foo()
    i = 0
    while i < o.num:
        i += 1



            

Reported by Pylint.

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

Line: 6 Column: 5

                  memoryview
except:
    print("SKIP")
    raise SystemExit

b = bytearray(10)
m = memoryview(b)[1:]
for i in range(len(m)):
    m[i] = i

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 20 Column: 5

              
# allocate lots of memory
for i in range(100000):
    [42, 42, 42, 42]

# check that the memoryview is still what we want
print(list(m))

# check that creating a memoryview of a memoryview retains the underlying data

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test memoryview retains pointer to original object/buffer
try:
    memoryview
except:
    print("SKIP")
    raise SystemExit

b = bytearray(10)
m = memoryview(b)[1:]

            

Reported by Pylint.

Consider using enumerate instead of iterating with range and len
Error

Line: 10 Column: 1

              
b = bytearray(10)
m = memoryview(b)[1:]
for i in range(len(m)):
    m[i] = i

# reclaim b, but hopefully not the buffer
b = None
import gc

            

Reported by Pylint.

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

Line: 14 Column: 1

                  m[i] = i

# reclaim b, but hopefully not the buffer
b = None
import gc
gc.collect()

# allocate lots of memory
for i in range(100000):

            

Reported by Pylint.

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

Line: 15 Column: 1

              
# reclaim b, but hopefully not the buffer
b = None
import gc
gc.collect()

# allocate lots of memory
for i in range(100000):
    [42, 42, 42, 42]

            

Reported by Pylint.

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

Line: 26 Column: 1

              print(list(m))

# check that creating a memoryview of a memoryview retains the underlying data
m = None
gc.collect()  # cleanup from previous test
m = memoryview(memoryview(bytearray(i for i in range(50)))[5:-5])
print(sum(m), list(m[:10]))
gc.collect()
for i in range(10):

            

Reported by Pylint.

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

Line: 10 Column: 9

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


async def task():
    print("task start")
    global_task.cancel()

            

Reported by Pylint.

Global variable 'global_task' undefined at the module level
Error

Line: 19 Column: 5

              

async def main():
    global global_task
    global_task = asyncio.create_task(task())
    try:
        await global_task
    except asyncio.CancelledError:
        print("main cancel")

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Test a task cancelling itself (currently unsupported)

try:
    import uasyncio as asyncio
except ImportError:
    try:
        import asyncio
    except ImportError:
        print("SKIP")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

                      raise SystemExit


async def task():
    print("task start")
    global_task.cancel()


async def main():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

                  global_task.cancel()


async def main():
    global global_task
    global_task = asyncio.create_task(task())
    try:
        await global_task
    except asyncio.CancelledError:

            

Reported by Pylint.

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

Line: 19 Column: 5

              

async def main():
    global global_task
    global_task = asyncio.create_task(task())
    try:
        await global_task
    except asyncio.CancelledError:
        print("main cancel")

            

Reported by Pylint.

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

Line: 30 Column: 1

              
try:
    asyncio.run(main())
except RuntimeError as er:
    print(er)

            

Reported by Pylint.

ports/nrf/examples/nrf52_pwm.py
7 issues
Unable to import 'machine'
Error

Line: 2 Column: 1

              import time
from machine import PWM, Pin


def pulse():
    for i in range(0, 101):
        p = PWM(0, Pin("P17", mode=Pin.OUT), freq=PWM.FREQ_16MHZ, duty=i, period=16000)
        p.init()
        time.sleep_ms(10)

            

Reported by Pylint.

Module 'time' has no 'sleep_ms' member
Error

Line: 9 Column: 9

                  for i in range(0, 101):
        p = PWM(0, Pin("P17", mode=Pin.OUT), freq=PWM.FREQ_16MHZ, duty=i, period=16000)
        p.init()
        time.sleep_ms(10)
        p.deinit()

    for i in range(0, 101):
        p = PWM(0, Pin("P17", mode=Pin.OUT), freq=PWM.FREQ_16MHZ, duty=100 - i, period=16000)
        p.init()

            

Reported by Pylint.

Module 'time' has no 'sleep_ms' member
Error

Line: 15 Column: 9

                  for i in range(0, 101):
        p = PWM(0, Pin("P17", mode=Pin.OUT), freq=PWM.FREQ_16MHZ, duty=100 - i, period=16000)
        p.init()
        time.sleep_ms(10)
        p.deinit()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import time
from machine import PWM, Pin


def pulse():
    for i in range(0, 101):
        p = PWM(0, Pin("P17", mode=Pin.OUT), freq=PWM.FREQ_16MHZ, duty=i, period=16000)
        p.init()
        time.sleep_ms(10)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              from machine import PWM, Pin


def pulse():
    for i in range(0, 101):
        p = PWM(0, Pin("P17", mode=Pin.OUT), freq=PWM.FREQ_16MHZ, duty=i, period=16000)
        p.init()
        time.sleep_ms(10)
        p.deinit()

            

Reported by Pylint.

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

Line: 7 Column: 9

              
def pulse():
    for i in range(0, 101):
        p = PWM(0, Pin("P17", mode=Pin.OUT), freq=PWM.FREQ_16MHZ, duty=i, period=16000)
        p.init()
        time.sleep_ms(10)
        p.deinit()

    for i in range(0, 101):

            

Reported by Pylint.

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

Line: 13 Column: 9

                      p.deinit()

    for i in range(0, 101):
        p = PWM(0, Pin("P17", mode=Pin.OUT), freq=PWM.FREQ_16MHZ, duty=100 - i, period=16000)
        p.init()
        time.sleep_ms(10)
        p.deinit()

            

Reported by Pylint.

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

Line: 1 Column: 1

              # test builtin locals()

x = 123
print(locals()['x'])

class A:
    y = 1
    def f(self):
        pass

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test builtin locals()

x = 123
print(locals()['x'])

class A:
    y = 1
    def f(self):
        pass

            

Reported by Pylint.

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

Line: 6 Column: 1

              x = 123
print(locals()['x'])

class A:
    y = 1
    def f(self):
        pass

    print('x' in locals())

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 6 Column: 1

              x = 123
print(locals()['x'])

class A:
    y = 1
    def f(self):
        pass

    print('x' in locals())

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              x = 123
print(locals()['x'])

class A:
    y = 1
    def f(self):
        pass

    print('x' in locals())

            

Reported by Pylint.

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

Line: 8 Column: 5

              
class A:
    y = 1
    def f(self):
        pass

    print('x' in locals())
    print(locals()['y'])
    print('f' in locals())

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 5

              
class A:
    y = 1
    def f(self):
        pass

    print('x' in locals())
    print(locals()['y'])
    print('f' in locals())

            

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.

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

Line: 5 Column: 5

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


def printbuf():
    print("--8<--")
    for y in range(h):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    import framebuf
except ImportError:
    print("SKIP")
    raise SystemExit


def printbuf():
    print("--8<--")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

                  raise SystemExit


def printbuf():
    print("--8<--")
    for y in range(h):
        for x in range(w):
            print("%02x" % buf[(x + y * w)], end="")
        print()

            

Reported by Pylint.

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

Line: 10 Column: 9

              
def printbuf():
    print("--8<--")
    for y in range(h):
        for x in range(w):
            print("%02x" % buf[(x + y * w)], end="")
        print()
    print("-->8--")


            

Reported by Pylint.

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

Line: 11 Column: 13

              def printbuf():
    print("--8<--")
    for y in range(h):
        for x in range(w):
            print("%02x" % buf[(x + y * w)], end="")
        print()
    print("-->8--")



            

Reported by Pylint.

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

Line: 17 Column: 1

                  print("-->8--")


w = 8
h = 5
buf = bytearray(w * h)
fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS8)

# fill

            

Reported by Pylint.

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

Line: 18 Column: 1

              

w = 8
h = 5
buf = bytearray(w * h)
fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS8)

# fill
fbuf.fill(0x55)

            

Reported by Pylint.

tests/internal_bench/var-6-instance-attr.py
7 issues
Unused argument 'num'
Error

Line: 9 Column: 10

                      self.num = 20000000


def test(num):
    o = Foo()
    i = 0
    while i < o.num:
        i += 1


            

Reported by Pylint.

Module name "var-6-instance-attr" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              import bench


class Foo:
    def __init__(self):
        self.num = 20000000


def test(num):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import bench


class Foo:
    def __init__(self):
        self.num = 20000000


def test(num):

            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              import bench


class Foo:
    def __init__(self):
        self.num = 20000000


def test(num):

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 4 Column: 1

              import bench


class Foo:
    def __init__(self):
        self.num = 20000000


def test(num):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

                      self.num = 20000000


def test(num):
    o = Foo()
    i = 0
    while i < o.num:
        i += 1


            

Reported by Pylint.

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

Line: 10 Column: 5

              

def test(num):
    o = Foo()
    i = 0
    while i < o.num:
        i += 1



            

Reported by Pylint.