The following issues were found

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/micropython/const2.py
29 issues
Unable to import 'micropython'
Error

Line: 3 Column: 1

              # check that consts are not replaced in anything except standalone identifiers

from micropython import const

X = const(1)
Y = const(2)
Z = const(3)

# import that uses a constant

            

Reported by Pylint.

Unable to import 'micropython'
Error

Line: 10 Column: 1

              Z = const(3)

# import that uses a constant
import micropython as X

print(globals()["X"])

# function name that matches a constant
def X():

            

Reported by Pylint.

function already defined line 5
Error

Line: 15 Column: 1

              print(globals()["X"])

# function name that matches a constant
def X():
    print("function X", X)


globals()["X"]()


            

Reported by Pylint.

class already defined line 5
Error

Line: 29 Column: 1

              f(1)

# class name that matches a constant
class X:
    def f(self):
        print("class X", X)


globals()["X"]().f()

            

Reported by Pylint.

Undefined variable 'C1'
Error

Line: 41 Column: 30

                  C1 = const(4)

    def X(self):
        print("method X", Y, C1, self.C1)


A().X()

            

Reported by Pylint.

Unused argument 'Y'
Error

Line: 22 Column: 1

              globals()["X"]()

# arguments that match a constant
def f(X, *Y, **Z):
    pass


f(1)


            

Reported by Pylint.

Unused argument 'X'
Error

Line: 22 Column: 7

              globals()["X"]()

# arguments that match a constant
def f(X, *Y, **Z):
    pass


f(1)


            

Reported by Pylint.

Redefining name 'Z' from outer scope (line 7)
Error

Line: 22 Column: 1

              globals()["X"]()

# arguments that match a constant
def f(X, *Y, **Z):
    pass


f(1)


            

Reported by Pylint.

Redefining name 'Y' from outer scope (line 6)
Error

Line: 22 Column: 1

              globals()["X"]()

# arguments that match a constant
def f(X, *Y, **Z):
    pass


f(1)


            

Reported by Pylint.

Redefining name 'X' from outer scope (line 5)
Error

Line: 22 Column: 7

              globals()["X"]()

# arguments that match a constant
def f(X, *Y, **Z):
    pass


f(1)


            

Reported by Pylint.

tests/basics/generator_pend_throw.py
28 issues
Generator 'generator' has no 'pend_throw' member
Error

Line: 19 Column: 1

              # Verify that an injected exception will be raised from next().
print(next(g))
print(next(g))
g.pend_throw(ValueError())

v = None
try:
    v = next(g)
except Exception as e:

            

Reported by Pylint.

Generator 'generator' has no 'pend_throw' member
Error

Line: 32 Column: 1

              
# Verify that pend_throw works on an unstarted coroutine.
g = gen()
g.pend_throw(OSError())
try:
    next(g)
except Exception as e:
    print("raised", repr(e))


            

Reported by Pylint.

Generator 'generator' has no 'pend_throw' member
Error

Line: 54 Column: 5

              
# Verify that you can't pend_throw from within the running coroutine.
def gen_pend_throw():
    g.pend_throw(ValueError())
    yield 1

g = gen_pend_throw()

try:

            

Reported by Pylint.

Generator 'generator' has no 'pend_throw' member
Error

Line: 78 Column: 1

              
g = gen_cancelled()
print(next(g))
g.pend_throw(CancelledError())
print(next(g))
# ...but not if the generator hasn't started.
g = gen_cancelled()
g.pend_throw(CancelledError())
try:

            

Reported by Pylint.

Generator 'generator' has no 'pend_throw' member
Error

Line: 82 Column: 1

              print(next(g))
# ...but not if the generator hasn't started.
g = gen_cancelled()
g.pend_throw(CancelledError())
try:
    next(g)
except Exception as e:
    print("raised", repr(e))


            

Reported by Pylint.

Generator 'generator' has no 'pend_throw' member
Error

Line: 92 Column: 12

              # Verify that calling pend_throw returns the previous exception.
g = gen()
next(g)
print(repr(g.pend_throw(CancelledError())))
print(repr(g.pend_throw(OSError)))


# Verify that you can pend_throw(None) to cancel a previous pend_throw.
g = gen()

            

Reported by Pylint.

Generator 'generator' has no 'pend_throw' member
Error

Line: 93 Column: 12

              g = gen()
next(g)
print(repr(g.pend_throw(CancelledError())))
print(repr(g.pend_throw(OSError)))


# Verify that you can pend_throw(None) to cancel a previous pend_throw.
g = gen()
next(g)

            

Reported by Pylint.

Generator 'generator' has no 'pend_throw' member
Error

Line: 99 Column: 1

              # Verify that you can pend_throw(None) to cancel a previous pend_throw.
g = gen()
next(g)
g.pend_throw(CancelledError())
print(repr(g.pend_throw(None)))
print(next(g))

            

Reported by Pylint.

Generator 'generator' has no 'pend_throw' member
Error

Line: 100 Column: 12

              g = gen()
next(g)
g.pend_throw(CancelledError())
print(repr(g.pend_throw(None)))
print(next(g))

            

Reported by Pylint.

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

Line: 13 Column: 5

                  g.pend_throw
except AttributeError:
    print("SKIP")
    raise SystemExit


# Verify that an injected exception will be raised from next().
print(next(g))
print(next(g))

            

Reported by Pylint.

tests/basics/try_finally_return3.py
28 issues
function already defined line 5
Error

Line: 17 Column: 1

              print(f())

# similar to above but more nesting
def f():
    try:
        raise ValueError
    finally:
        print(1)
        try:

            

Reported by Pylint.

function already defined line 5
Error

Line: 33 Column: 1

              print(f())

# similar to above but even more nesting
def f():
    try:
        raise ValueError
    finally:
        print(1)
        try:

            

Reported by Pylint.

function already defined line 5
Error

Line: 50 Column: 1

              print(f())

# upon return some try's are active, some finally's are active, some inactive
def f():
    try:
        try:
            pass
        finally:
            print(2)

            

Reported by Pylint.

function already defined line 5
Error

Line: 62 Column: 1

              print(f())

# same as above but raise instead of pass
def f():
    try:
        try:
            raise ValueError
        finally:
            print(2)

            

Reported by Pylint.

function already defined line 5
Error

Line: 74 Column: 1

              print(f())

# upon return exception stack holds: active finally, inactive finally, active finally
def f():
    try:
        raise Exception
    finally:
        print(1)
        try:

            

Reported by Pylint.

function already defined line 5
Error

Line: 90 Column: 1

              print(f())

# same as above but raise instead of pass in innermost try block
def f():
    try:
        raise Exception
    finally:
        print(1)
        try:

            

Reported by Pylint.

return statement in finally block may swallow exception
Error

Line: 13 Column: 13

                      try:
            raise ValueError
        finally:
            return 42
print(f())

# similar to above but more nesting
def f():
    try:

            

Reported by Pylint.

return statement in finally block may swallow exception
Error

Line: 29 Column: 17

                          try:
                pass
            finally:
                return 42
print(f())

# similar to above but even more nesting
def f():
    try:

            

Reported by Pylint.

return statement in finally block may swallow exception
Error

Line: 46 Column: 17

                              raise Exception
            finally:
                print(3)
                return 42
print(f())

# upon return some try's are active, some finally's are active, some inactive
def f():
    try:

            

Reported by Pylint.

return statement in finally block may swallow exception
Error

Line: 56 Column: 13

                          pass
        finally:
            print(2)
            return 42
    finally:
        print(1)
print(f())

# same as above but raise instead of pass

            

Reported by Pylint.

tests/extmod/vfs_fat_finaliser.py
28 issues
Unable to import 'micropython'
Error

Line: 47 Column: 1

              # is a special case because file objects use a finaliser and allocating with a
# finaliser is a different path to normal allocation.  It would be better to
# test this in the core tests but there are no core objects that use finaliser.
import micropython

micropython.heap_lock()
try:
    vfs.open("x", "r")
except MemoryError:

            

Reported by Pylint.

Unused import uerrno
Error

Line: 4 Column: 5

              # Test VfsFat class and its finaliser

try:
    import uerrno, uos

    uos.VfsFat
except (ImportError, AttributeError):
    print("SKIP")
    raise SystemExit

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 6 Column: 5

              try:
    import uerrno, uos

    uos.VfsFat
except (ImportError, AttributeError):
    print("SKIP")
    raise SystemExit



            

Reported by Pylint.

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

Line: 9 Column: 5

                  uos.VfsFat
except (ImportError, AttributeError):
    print("SKIP")
    raise SystemExit


class RAMBlockDevice:
    def __init__(self, blocks, sec_size=512):
        self.sec_size = sec_size

            

Reported by Pylint.

Redefining name 'n' from outer scope (line 68)
Error

Line: 17 Column: 26

                      self.sec_size = sec_size
        self.data = bytearray(blocks * self.sec_size)

    def readblocks(self, n, buf):
        for i in range(len(buf)):
            buf[i] = self.data[n * self.sec_size + i]

    def writeblocks(self, n, buf):
        for i in range(len(buf)):

            

Reported by Pylint.

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

Line: 18 Column: 13

                      self.data = bytearray(blocks * self.sec_size)

    def readblocks(self, n, buf):
        for i in range(len(buf)):
            buf[i] = self.data[n * self.sec_size + i]

    def writeblocks(self, n, buf):
        for i in range(len(buf)):
            self.data[n * self.sec_size + i] = buf[i]

            

Reported by Pylint.

Redefining name 'n' from outer scope (line 68)
Error

Line: 21 Column: 27

                      for i in range(len(buf)):
            buf[i] = self.data[n * self.sec_size + i]

    def writeblocks(self, n, buf):
        for i in range(len(buf)):
            self.data[n * self.sec_size + i] = buf[i]

    def ioctl(self, op, arg):
        if op == 4:  # MP_BLOCKDEV_IOCTL_BLOCK_COUNT

            

Reported by Pylint.

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

Line: 22 Column: 13

                          buf[i] = self.data[n * self.sec_size + i]

    def writeblocks(self, n, buf):
        for i in range(len(buf)):
            self.data[n * self.sec_size + i] = buf[i]

    def ioctl(self, op, arg):
        if op == 4:  # MP_BLOCKDEV_IOCTL_BLOCK_COUNT
            return len(self.data) // self.sec_size

            

Reported by Pylint.

Unused argument 'arg'
Error

Line: 25 Column: 25

                      for i in range(len(buf)):
            self.data[n * self.sec_size + i] = buf[i]

    def ioctl(self, op, arg):
        if op == 4:  # MP_BLOCKDEV_IOCTL_BLOCK_COUNT
            return len(self.data) // self.sec_size
        if op == 5:  # MP_BLOCKDEV_IOCTL_BLOCK_SIZE
            return self.sec_size


            

Reported by Pylint.

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

Line: 37 Column: 5

                  bdev = RAMBlockDevice(50)
except MemoryError:
    print("SKIP")
    raise SystemExit

# Format block device and create VFS object
uos.VfsFat.mkfs(bdev)
vfs = uos.VfsFat(bdev)


            

Reported by Pylint.

tests/micropython/extreme_exc.py
28 issues
Unable to import 'micropython'
Error

Line: 3 Column: 1

              # test some extreme cases of allocating exceptions and tracebacks

import micropython

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

    def stackless():

            

Reported by Pylint.

Unexpected keyword argument 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' in function call
Error

Line: 107 Column: 9

              
    micropython.heap_lock()
    try:
        f(
            abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=1
        )
    except Exception as er:
        e = er
    micropython.heap_unlock()

            

Reported by Pylint.

Unexpected keyword argument 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' in function call
Error

Line: 124 Column: 9

                      except MemoryError:
            break
    try:
        f(
            abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=1
        )
    except Exception as er:
        e = er
    lst[0][0] = None

            

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

# some ports need to allocate heap for the emergency exception
try:
    micropython.alloc_emergency_exception_buf(256)
except AttributeError:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 110 Column: 12

                      f(
            abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=1
        )
    except Exception as er:
        e = er
    micropython.heap_unlock()
    print(repr(e)[:10])

    # create an exception with a long formatted error message while heap is low

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 127 Column: 12

                      f(
            abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=1
        )
    except Exception as er:
        e = er
    lst[0][0] = None
    lst = None
    print(repr(e)[:10])


            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 141 Column: 12

                  micropython.heap_lock()
    try:
        g()
    except Exception as er:
        e = er
    micropython.heap_unlock()
    print(repr(e)[:13])

    # create an exception on the heap with some traceback on the heap, but then

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 151 Column: 5

                  exc = Exception("my exception")
    try:
        raise exc
    except:
        pass

    def h(e):
        raise e


            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 160 Column: 12

                  micropython.heap_lock()
    try:
        h(exc)
    except Exception as er:
        e = er
    micropython.heap_unlock()
    print(repr(e))



            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test some extreme cases of allocating exceptions and tracebacks

import micropython

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

    def stackless():

            

Reported by Pylint.

tools/dfu.py
28 issues
Uses of a deprecated module 'optparse'
Error

Line: 8 Column: 1

              # see http://www.gnu.org/licenses/lgpl-3.0.txt

import sys, struct, zlib, os
from optparse import OptionParser

DEFAULT_DEVICE = "0x0483:0xdf11"


def named(tuple, names):

            

Reported by Pylint.

Redefining built-in 'tuple'
Error

Line: 13 Column: 11

              DEFAULT_DEVICE = "0x0483:0xdf11"


def named(tuple, names):
    return dict(zip(names.split(), tuple))


def consume(fmt, data, names):
    n = struct.calcsize(fmt)

            

Reported by Pylint.

Redefining name 'target' from outer scope (line 129)
Error

Line: 50 Column: 9

                          % tprefix
        )
        tsize = tprefix["size"]
        target, data = data[:tsize], data[tsize:]
        for e in range(tprefix["elements"]):
            eprefix, target = consume("<2I", target, "address size")
            eprefix["num"] = e
            print("  %(num)d, address: 0x%(address)08x, size: %(size)d" % eprefix)
            esize = eprefix["size"]

            

Reported by Pylint.

Redefining name 'device' from outer scope (line 146)
Error

Line: 75 Column: 26

                      print("PARSE ERROR")


def build(file, targets, device=DEFAULT_DEVICE):
    data = b""
    for t, target in enumerate(targets):
        tdata = b""
        for image in target:
            # pad image to 8 bytes (needed at least for L476)

            

Reported by Pylint.

Redefining name 'target' from outer scope (line 129)
Error

Line: 77 Column: 12

              
def build(file, targets, device=DEFAULT_DEVICE):
    data = b""
    for t, target in enumerate(targets):
        tdata = b""
        for image in target:
            # pad image to 8 bytes (needed at least for L476)
            pad = (8 - len(image["data"]) % 8) % 8
            image["data"] = image["data"] + bytes(bytearray(8)[0:pad])

            

Reported by Pylint.

Unused variable 't'
Error

Line: 77 Column: 9

              
def build(file, targets, device=DEFAULT_DEVICE):
    data = b""
    for t, target in enumerate(targets):
        tdata = b""
        for image in target:
            # pad image to 8 bytes (needed at least for L476)
            pad = (8 - len(image["data"]) % 8) % 8
            image["data"] = image["data"] + bytes(bytearray(8)[0:pad])

            

Reported by Pylint.

Redefining name 'v' from outer scope (line 150)
Error

Line: 90 Column: 5

                      )
        data += tdata
    data = struct.pack("<5sBIB", b"DfuSe", 1, len(data) + 11, len(targets)) + data
    v, d = map(lambda x: int(x, 0) & 0xFFFF, device.split(":", 1))
    data += struct.pack("<4H3sB", 0, d, v, 0x011A, b"UFD", 16)
    crc = compute_crc(data)
    data += struct.pack("<I", crc)
    open(file, "wb").write(data)


            

Reported by Pylint.

Redefining name 'd' from outer scope (line 150)
Error

Line: 90 Column: 8

                      )
        data += tdata
    data = struct.pack("<5sBIB", b"DfuSe", 1, len(data) + 11, len(targets)) + data
    v, d = map(lambda x: int(x, 0) & 0xFFFF, device.split(":", 1))
    data += struct.pack("<4H3sB", 0, d, v, 0x011A, b"UFD", 16)
    crc = compute_crc(data)
    data += struct.pack("<I", crc)
    open(file, "wb").write(data)


            

Reported by Pylint.

No exception type(s) specified
Error

Line: 151 Column: 9

                          device = options.device
        try:
            v, d = map(lambda x: int(x, 0) & 0xFFFF, device.split(":", 1))
        except:
            print("Invalid device '%s'." % device)
            sys.exit(1)
        build(outfile, [target], device)
    elif len(args) == 1:
        infile = args[0]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/python

# Written by Antonio Galea - 2010/11/18
# Distributed under Gnu LGPL 3.0
# see http://www.gnu.org/licenses/lgpl-3.0.txt

import sys, struct, zlib, os
from optparse import OptionParser


            

Reported by Pylint.

examples/bluetooth/ble_uart_repl.py
27 issues
Unable to import 'bluetooth'
Error

Line: 6 Column: 1

              # Tested with the Adafruit Bluefruit app on Android.
# Set the EoL characters to \r\n.

import bluetooth
import io
import os
import micropython
import machine


            

Reported by Pylint.

Unable to import 'micropython'
Error

Line: 9 Column: 1

              import bluetooth
import io
import os
import micropython
import machine

from ble_uart_peripheral import BLEUART

_MP_STREAM_POLL = const(3)

            

Reported by Pylint.

Unable to import 'machine'
Error

Line: 10 Column: 1

              import io
import os
import micropython
import machine

from ble_uart_peripheral import BLEUART

_MP_STREAM_POLL = const(3)
_MP_STREAM_POLL_RD = const(0x0001)

            

Reported by Pylint.

Undefined variable 'const'
Error

Line: 14 Column: 19

              
from ble_uart_peripheral import BLEUART

_MP_STREAM_POLL = const(3)
_MP_STREAM_POLL_RD = const(0x0001)

# TODO: Remove this when STM32 gets machine.Timer.
if hasattr(machine, "Timer"):
    _timer = machine.Timer(-1)

            

Reported by Pylint.

Undefined variable 'const'
Error

Line: 15 Column: 22

              from ble_uart_peripheral import BLEUART

_MP_STREAM_POLL = const(3)
_MP_STREAM_POLL_RD = const(0x0001)

# TODO: Remove this when STM32 gets machine.Timer.
if hasattr(machine, "Timer"):
    _timer = machine.Timer(-1)
else:

            

Reported by Pylint.

Module 'os' has no 'dupterm_notify' member
Error

Line: 44 Column: 13

                  def _on_rx(self):
        # Needed for ESP32.
        if hasattr(os, "dupterm_notify"):
            os.dupterm_notify(None)

    def read(self, sz=None):
        return self._uart.read(sz)

    def readinto(self, buf):

            

Reported by Pylint.

Module 'os' has no 'dupterm' member
Error

Line: 82 Column: 5

                  uart = BLEUART(ble, name="mpy-repl")
    stream = BLEUARTStream(uart)

    os.dupterm(stream)

            

Reported by Pylint.

TODO: Remove this when STM32 gets machine.Timer.
Error

Line: 17 Column: 3

              _MP_STREAM_POLL = const(3)
_MP_STREAM_POLL_RD = const(0x0001)

# TODO: Remove this when STM32 gets machine.Timer.
if hasattr(machine, "Timer"):
    _timer = machine.Timer(-1)
else:
    _timer = None


            

Reported by Pylint.

__init__ method from base class 'IOBase' is not called
Error

Line: 36 Column: 5

              
# Simple buffering stream to support the dupterm requirements.
class BLEUARTStream(io.IOBase):
    def __init__(self, uart):
        self._uart = uart
        self._tx_buf = bytearray()
        self._uart.irq(self._on_rx)

    def _on_rx(self):

            

Reported by Pylint.

Unused argument 'arg'
Error

Line: 57 Column: 25

                          buf[i] = avail[i]
        return len(avail)

    def ioctl(self, op, arg):
        if op == _MP_STREAM_POLL:
            if self._uart.any():
                return _MP_STREAM_POLL_RD
        return 0


            

Reported by Pylint.

examples/pyb.py
27 issues
Unused import time
Error

Line: 2 Column: 1

              # pyboard testing functions for CPython
import time


def delay(n):
    # time.sleep(float(n) / 1000)
    pass



            

Reported by Pylint.

Unused argument 'n'
Error

Line: 5 Column: 11

              import time


def delay(n):
    # time.sleep(float(n) / 1000)
    pass


rand_seed = 1

            

Reported by Pylint.

Using the global statement
Error

Line: 14 Column: 5

              

def rng():
    global rand_seed
    # for these choice of numbers, see P L'Ecuyer, "Tables of linear congruential generators of different sizes and good lattice structure"
    rand_seed = (rand_seed * 653276) % 8388593
    return rand_seed



            

Reported by Pylint.

Unused argument 'port'
Error

Line: 23 Column: 24

              # LCD testing object for PC
# uses double buffering
class LCD:
    def __init__(self, port):
        self.width = 128
        self.height = 32
        self.buf1 = [[0 for x in range(self.width)] for y in range(self.height)]
        self.buf2 = [[0 for x in range(self.width)] for y in range(self.height)]


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # pyboard testing functions for CPython
import time


def delay(n):
    # time.sleep(float(n) / 1000)
    pass



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              import time


def delay(n):
    # time.sleep(float(n) / 1000)
    pass


rand_seed = 1

            

Reported by Pylint.

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

Line: 5 Column: 1

              import time


def delay(n):
    # time.sleep(float(n) / 1000)
    pass


rand_seed = 1

            

Reported by Pylint.

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

Line: 10 Column: 1

                  pass


rand_seed = 1


def rng():
    global rand_seed
    # for these choice of numbers, see P L'Ecuyer, "Tables of linear congruential generators of different sizes and good lattice structure"

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              rand_seed = 1


def rng():
    global rand_seed
    # for these choice of numbers, see P L'Ecuyer, "Tables of linear congruential generators of different sizes and good lattice structure"
    rand_seed = (rand_seed * 653276) % 8388593
    return rand_seed


            

Reported by Pylint.

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

Line: 14 Column: 5

              

def rng():
    global rand_seed
    # for these choice of numbers, see P L'Ecuyer, "Tables of linear congruential generators of different sizes and good lattice structure"
    rand_seed = (rand_seed * 653276) % 8388593
    return rand_seed



            

Reported by Pylint.

tests/extmod/vfs_lfs_file.py
27 issues
Statement seems to have no effect
Error

Line: 6 Column: 5

              try:
    import uos

    uos.VfsLfs1
    uos.VfsLfs2
except (ImportError, AttributeError):
    print("SKIP")
    raise SystemExit


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 7 Column: 5

                  import uos

    uos.VfsLfs1
    uos.VfsLfs2
except (ImportError, AttributeError):
    print("SKIP")
    raise SystemExit



            

Reported by Pylint.

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

Line: 10 Column: 5

                  uos.VfsLfs2
except (ImportError, AttributeError):
    print("SKIP")
    raise SystemExit


class RAMBlockDevice:
    ERASE_BLOCK_SIZE = 1024


            

Reported by Pylint.

Unused argument 'arg'
Error

Line: 29 Column: 25

                      for i in range(len(buf)):
            self.data[addr + i] = buf[i]

    def ioctl(self, op, arg):
        if op == 4:  # block count
            return len(self.data) // self.ERASE_BLOCK_SIZE
        if op == 5:  # block size
            return self.ERASE_BLOCK_SIZE
        if op == 6:  # erase block

            

Reported by Pylint.

Redefining name 'bdev' from outer scope (line 119)
Error

Line: 38 Column: 10

                          return 0


def test(bdev, vfs_class):
    print("test", vfs_class)

    # mkfs
    vfs_class.mkfs(bdev)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Test for VfsLittle using a RAM device, file IO

try:
    import uos

    uos.VfsLfs1
    uos.VfsLfs2
except (ImportError, AttributeError):
    print("SKIP")

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

                  raise SystemExit


class RAMBlockDevice:
    ERASE_BLOCK_SIZE = 1024

    def __init__(self, blocks):
        self.data = bytearray(blocks * self.ERASE_BLOCK_SIZE)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

                  def __init__(self, blocks):
        self.data = bytearray(blocks * self.ERASE_BLOCK_SIZE)

    def readblocks(self, block, buf, off):
        addr = block * self.ERASE_BLOCK_SIZE + off
        for i in range(len(buf)):
            buf[i] = self.data[addr + i]

    def writeblocks(self, block, buf, off):

            

Reported by Pylint.

Consider using enumerate instead of iterating with range and len
Error

Line: 21 Column: 9

              
    def readblocks(self, block, buf, off):
        addr = block * self.ERASE_BLOCK_SIZE + off
        for i in range(len(buf)):
            buf[i] = self.data[addr + i]

    def writeblocks(self, block, buf, off):
        addr = block * self.ERASE_BLOCK_SIZE + off
        for i in range(len(buf)):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                      for i in range(len(buf)):
            buf[i] = self.data[addr + i]

    def writeblocks(self, block, buf, off):
        addr = block * self.ERASE_BLOCK_SIZE + off
        for i in range(len(buf)):
            self.data[addr + i] = buf[i]

    def ioctl(self, op, arg):

            

Reported by Pylint.