The following issues were found

examples/network/http_client_ssl.py
8 issues
No exception type(s) specified
Error

Line: 3 Column: 1

              try:
    import usocket as _socket
except:
    import _socket
try:
    import ussl as ssl
except:
    import ssl


            

Reported by Pylint.

No exception type(s) specified
Error

Line: 7 Column: 1

                  import _socket
try:
    import ussl as ssl
except:
    import ssl


def main(use_stream=True):
    s = _socket.socket()

            

Reported by Pylint.

Using deprecated method wrap_socket()
Error

Line: 21 Column: 9

                  print("Connect address:", addr)
    s.connect(addr)

    s = ssl.wrap_socket(s)
    print(s)

    if use_stream:
        # Both CPython and MicroPython SSLSocket objects support read() and
        # write() methods.

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    import usocket as _socket
except:
    import _socket
try:
    import ussl as ssl
except:
    import ssl


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

                  import ssl


def main(use_stream=True):
    s = _socket.socket()

    ai = _socket.getaddrinfo("google.com", 443)
    print("Address infos:", ai)
    addr = ai[0][-1]

            

Reported by Pylint.

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

Line: 12 Column: 5

              

def main(use_stream=True):
    s = _socket.socket()

    ai = _socket.getaddrinfo("google.com", 443)
    print("Address infos:", ai)
    addr = ai[0][-1]


            

Reported by Pylint.

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

Line: 14 Column: 5

              def main(use_stream=True):
    s = _socket.socket()

    ai = _socket.getaddrinfo("google.com", 443)
    print("Address infos:", ai)
    addr = ai[0][-1]

    print("Connect address:", addr)
    s.connect(addr)

            

Reported by Pylint.

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

Line: 21 Column: 5

                  print("Connect address:", addr)
    s.connect(addr)

    s = ssl.wrap_socket(s)
    print(s)

    if use_stream:
        # Both CPython and MicroPython SSLSocket objects support read() and
        # write() methods.

            

Reported by Pylint.

tests/basics/except_match_tuple.py
8 issues
Undefined variable 'fail'
Error

Line: 4 Column: 5

              # test exception matching against a tuple

try:
    fail
except (Exception,):
    print('except 1')

try:
    fail

            

Reported by Pylint.

Undefined variable 'fail'
Error

Line: 9 Column: 5

                  print('except 1')

try:
    fail
except (Exception, Exception):
    print('except 2')

try:
    fail

            

Reported by Pylint.

Undefined variable 'fail'
Error

Line: 19 Column: 5

                  print('except 3')

try:
    fail
except (TypeError, ValueError, Exception):
    print('except 4')

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 5 Column: 8

              
try:
    fail
except (Exception,):
    print('except 1')

try:
    fail
except (Exception, Exception):

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 10 Column: 8

              
try:
    fail
except (Exception, Exception):
    print('except 2')

try:
    fail
except (TypeError, NameError):

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 10 Column: 8

              
try:
    fail
except (Exception, Exception):
    print('except 2')

try:
    fail
except (TypeError, NameError):

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 20 Column: 8

              
try:
    fail
except (TypeError, ValueError, Exception):
    print('except 4')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test exception matching against a tuple

try:
    fail
except (Exception,):
    print('except 1')

try:
    fail

            

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.

tests/extmod/uheapq1.py
8 issues
Unable to import 'uheapq'
Error

Line: 2 Column: 5

              try:
    import uheapq as heapq
except:
    try:
        import heapq
    except ImportError:
        print("SKIP")
        raise SystemExit


            

Reported by Pylint.

No exception type(s) specified
Error

Line: 3 Column: 1

              try:
    import uheapq as heapq
except:
    try:
        import heapq
    except ImportError:
        print("SKIP")
        raise SystemExit


            

Reported by Pylint.

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

Line: 8 Column: 9

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

try:
    heapq.heappop([])
except IndexError:
    print("IndexError")

            

Reported by Pylint.

Redefining name 'h' from outer scope (line 28)
Error

Line: 21 Column: 19

                  print("TypeError")


def pop_and_print(h):
    l = []
    while h:
        l.append(str(heapq.heappop(h)))
    print(" ".join(l))


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    import uheapq as heapq
except:
    try:
        import heapq
    except ImportError:
        print("SKIP")
        raise SystemExit


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 1

                  print("TypeError")


def pop_and_print(h):
    l = []
    while h:
        l.append(str(heapq.heappop(h)))
    print(" ".join(l))


            

Reported by Pylint.

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

Line: 21 Column: 1

                  print("TypeError")


def pop_and_print(h):
    l = []
    while h:
        l.append(str(heapq.heappop(h)))
    print(" ".join(l))


            

Reported by Pylint.

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

Line: 22 Column: 5

              

def pop_and_print(h):
    l = []
    while h:
        l.append(str(heapq.heappop(h)))
    print(" ".join(l))



            

Reported by Pylint.

tests/cpydiff/core_import_split_ns_pkgs.py
8 issues
Unable to import 'subpkg.foo'
Error

Line: 12 Column: 1

              sys.path.append(sys.path[1] + "/modules")
sys.path.append(sys.path[1] + "/modules2")

import subpkg.foo
import subpkg.bar

print("Two modules of a split namespace package imported")

            

Reported by Pylint.

Unable to import 'subpkg.bar'
Error

Line: 13 Column: 1

              sys.path.append(sys.path[1] + "/modules2")

import subpkg.foo
import subpkg.bar

print("Two modules of a split namespace package imported")

            

Reported by Pylint.

Unused import subpkg.foo
Error

Line: 12 Column: 1

              sys.path.append(sys.path[1] + "/modules")
sys.path.append(sys.path[1] + "/modules2")

import subpkg.foo
import subpkg.bar

print("Two modules of a split namespace package imported")

            

Reported by Pylint.

Unused import subpkg.bar
Error

Line: 13 Column: 1

              sys.path.append(sys.path[1] + "/modules2")

import subpkg.foo
import subpkg.bar

print("Two modules of a split namespace package imported")

            

Reported by Pylint.

Line too long (132/100)
Error

Line: 4 Column: 1

              """
categories: Core,import
description: MicroPython does't support namespace packages split across filesystem.
cause: MicroPython's import system is highly optimized for simplicity, minimal memory usage, and minimal filesystem search overhead.
workaround: Don't install modules belonging to the same namespace package in different directories. For MicroPython, it's recommended to have at most 3-component module search paths: for your current application, per-user (writable), system-wide (non-writable).
"""
import sys

sys.path.append(sys.path[1] + "/modules")

            

Reported by Pylint.

Line too long (261/100)
Error

Line: 5 Column: 1

              categories: Core,import
description: MicroPython does't support namespace packages split across filesystem.
cause: MicroPython's import system is highly optimized for simplicity, minimal memory usage, and minimal filesystem search overhead.
workaround: Don't install modules belonging to the same namespace package in different directories. For MicroPython, it's recommended to have at most 3-component module search paths: for your current application, per-user (writable), system-wide (non-writable).
"""
import sys

sys.path.append(sys.path[1] + "/modules")
sys.path.append(sys.path[1] + "/modules2")

            

Reported by Pylint.

Import "import subpkg.foo" should be placed at the top of the module
Error

Line: 12 Column: 1

              sys.path.append(sys.path[1] + "/modules")
sys.path.append(sys.path[1] + "/modules2")

import subpkg.foo
import subpkg.bar

print("Two modules of a split namespace package imported")

            

Reported by Pylint.

Import "import subpkg.bar" should be placed at the top of the module
Error

Line: 13 Column: 1

              sys.path.append(sys.path[1] + "/modules2")

import subpkg.foo
import subpkg.bar

print("Two modules of a split namespace package imported")

            

Reported by Pylint.

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

Line: 11 Column: 9

                      import io, json
    except ImportError:
        print("SKIP")
        raise SystemExit

if not hasattr(io, "IOBase"):
    print("SKIP")
    raise SystemExit


            

Reported by Pylint.

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

Line: 20 Column: 5

              
# a user stream that only has the write method
class S(io.IOBase):
    def __init__(self):
        self.buf = ""

    def write(self, buf):
        if type(buf) == bytearray:
            # uPy passes a bytearray, CPython passes a str

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test ujson.dump in combination with uio.IOBase

try:
    import uio as io
    import ujson as json
except ImportError:
    try:
        import io, json
    except ImportError:

            

Reported by Pylint.

Multiple imports on one line (io, json)
Error

Line: 8 Column: 9

                  import ujson as json
except ImportError:
    try:
        import io, json
    except ImportError:
        print("SKIP")
        raise SystemExit

if not hasattr(io, "IOBase"):

            

Reported by Pylint.

Missing class docstring
Error

Line: 19 Column: 1

              

# a user stream that only has the write method
class S(io.IOBase):
    def __init__(self):
        self.buf = ""

    def write(self, buf):
        if type(buf) == bytearray:

            

Reported by Pylint.

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

Line: 19 Column: 1

              

# a user stream that only has the write method
class S(io.IOBase):
    def __init__(self):
        self.buf = ""

    def write(self, buf):
        if type(buf) == bytearray:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

                  def __init__(self):
        self.buf = ""

    def write(self, buf):
        if type(buf) == bytearray:
            # uPy passes a bytearray, CPython passes a str
            buf = str(buf, "ascii")
        self.buf += buf
        return len(buf)

            

Reported by Pylint.

Using type() instead of isinstance() for a typecheck.
Error

Line: 24 Column: 12

                      self.buf = ""

    def write(self, buf):
        if type(buf) == bytearray:
            # uPy passes a bytearray, CPython passes a str
            buf = str(buf, "ascii")
        self.buf += buf
        return len(buf)


            

Reported by Pylint.

ports/stm32/usbhost/Class/MSC/Src/usbh_msc_scsi.c
8 issues
The address of local variable 'address' is accessed at non-zero index.
Error

Line: 346 CWE codes: 758

                  MSC_Handle->hbot.cbw.field.CB[0]  = OPCODE_WRITE10; 
    
    /*logical block address*/
    MSC_Handle->hbot.cbw.field.CB[2]  = (((uint8_t*)&address)[3]);
    MSC_Handle->hbot.cbw.field.CB[3]  = (((uint8_t*)&address)[2]);
    MSC_Handle->hbot.cbw.field.CB[4]  = (((uint8_t*)&address)[1]);
    MSC_Handle->hbot.cbw.field.CB[5]  = (((uint8_t*)&address)[0]);
    
    

            

Reported by Cppcheck.

The address of local variable 'address' is accessed at non-zero index.
Error

Line: 347 CWE codes: 758

                  
    /*logical block address*/
    MSC_Handle->hbot.cbw.field.CB[2]  = (((uint8_t*)&address)[3]);
    MSC_Handle->hbot.cbw.field.CB[3]  = (((uint8_t*)&address)[2]);
    MSC_Handle->hbot.cbw.field.CB[4]  = (((uint8_t*)&address)[1]);
    MSC_Handle->hbot.cbw.field.CB[5]  = (((uint8_t*)&address)[0]);
    
    
    /*Tranfer length */

            

Reported by Cppcheck.

The address of local variable 'address' is accessed at non-zero index.
Error

Line: 348 CWE codes: 758

                  /*logical block address*/
    MSC_Handle->hbot.cbw.field.CB[2]  = (((uint8_t*)&address)[3]);
    MSC_Handle->hbot.cbw.field.CB[3]  = (((uint8_t*)&address)[2]);
    MSC_Handle->hbot.cbw.field.CB[4]  = (((uint8_t*)&address)[1]);
    MSC_Handle->hbot.cbw.field.CB[5]  = (((uint8_t*)&address)[0]);
    
    
    /*Tranfer length */
    MSC_Handle->hbot.cbw.field.CB[7]  = (((uint8_t *)&length)[1]) ; 

            

Reported by Cppcheck.

The address of local variable 'length' is accessed at non-zero index.
Error

Line: 353 CWE codes: 758

                  
    
    /*Tranfer length */
    MSC_Handle->hbot.cbw.field.CB[7]  = (((uint8_t *)&length)[1]) ; 
    MSC_Handle->hbot.cbw.field.CB[8]  = (((uint8_t *)&length)[0]) ; 

    
    MSC_Handle->hbot.state = BOT_SEND_CBW;
    MSC_Handle->hbot.cmd_state = BOT_CMD_WAIT;

            

Reported by Cppcheck.

The address of local variable 'address' is accessed at non-zero index.
Error

Line: 406 CWE codes: 758

                  MSC_Handle->hbot.cbw.field.CB[0]  = OPCODE_READ10; 
    
    /*logical block address*/
    MSC_Handle->hbot.cbw.field.CB[2]  = (((uint8_t*)&address)[3]);
    MSC_Handle->hbot.cbw.field.CB[3]  = (((uint8_t*)&address)[2]);
    MSC_Handle->hbot.cbw.field.CB[4]  = (((uint8_t*)&address)[1]);
    MSC_Handle->hbot.cbw.field.CB[5]  = (((uint8_t*)&address)[0]);
    
    

            

Reported by Cppcheck.

The address of local variable 'address' is accessed at non-zero index.
Error

Line: 407 CWE codes: 758

                  
    /*logical block address*/
    MSC_Handle->hbot.cbw.field.CB[2]  = (((uint8_t*)&address)[3]);
    MSC_Handle->hbot.cbw.field.CB[3]  = (((uint8_t*)&address)[2]);
    MSC_Handle->hbot.cbw.field.CB[4]  = (((uint8_t*)&address)[1]);
    MSC_Handle->hbot.cbw.field.CB[5]  = (((uint8_t*)&address)[0]);
    
    
    /*Tranfer length */

            

Reported by Cppcheck.

The address of local variable 'address' is accessed at non-zero index.
Error

Line: 408 CWE codes: 758

                  /*logical block address*/
    MSC_Handle->hbot.cbw.field.CB[2]  = (((uint8_t*)&address)[3]);
    MSC_Handle->hbot.cbw.field.CB[3]  = (((uint8_t*)&address)[2]);
    MSC_Handle->hbot.cbw.field.CB[4]  = (((uint8_t*)&address)[1]);
    MSC_Handle->hbot.cbw.field.CB[5]  = (((uint8_t*)&address)[0]);
    
    
    /*Tranfer length */
    MSC_Handle->hbot.cbw.field.CB[7]  = (((uint8_t *)&length)[1]) ; 

            

Reported by Cppcheck.

The address of local variable 'length' is accessed at non-zero index.
Error

Line: 413 CWE codes: 758

                  
    
    /*Tranfer length */
    MSC_Handle->hbot.cbw.field.CB[7]  = (((uint8_t *)&length)[1]) ; 
    MSC_Handle->hbot.cbw.field.CB[8]  = (((uint8_t *)&length)[0]) ; 

    
    MSC_Handle->hbot.state = BOT_SEND_CBW;
    MSC_Handle->hbot.cmd_state = BOT_CMD_WAIT;

            

Reported by Cppcheck.

tests/basics/class_super_aslocal.py
8 issues
Redefining built-in 'super'
Error

Line: 5 Column: 9

              
class A:
    def foo(self):
        super = [1, 2]
        super.pop()
        print(super)

A().foo()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test using the name "super" as a local variable

class A:
    def foo(self):
        super = [1, 2]
        super.pop()
        print(super)

A().foo()

            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              # test using the name "super" as a local variable

class A:
    def foo(self):
        super = [1, 2]
        super.pop()
        print(super)

A().foo()

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 3 Column: 1

              # test using the name "super" as a local variable

class A:
    def foo(self):
        super = [1, 2]
        super.pop()
        print(super)

A().foo()

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test using the name "super" as a local variable

class A:
    def foo(self):
        super = [1, 2]
        super.pop()
        print(super)

A().foo()

            

Reported by Pylint.

Method could be a function
Error

Line: 4 Column: 5

              # test using the name "super" as a local variable

class A:
    def foo(self):
        super = [1, 2]
        super.pop()
        print(super)

A().foo()

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 4 Column: 5

              # test using the name "super" as a local variable

class A:
    def foo(self):
        super = [1, 2]
        super.pop()
        print(super)

A().foo()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 5

              # test using the name "super" as a local variable

class A:
    def foo(self):
        super = [1, 2]
        super.pop()
        print(super)

A().foo()

            

Reported by Pylint.

tests/basics/class_str.py
8 issues
Missing class docstring
Error

Line: 1 Column: 1

              class C1:
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return "str<C1 {}>".format(self.value)

class C2:
    def __init__(self, value):

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 1 Column: 1

              class C1:
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return "str<C1 {}>".format(self.value)

class C2:
    def __init__(self, value):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              class C1:
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return "str<C1 {}>".format(self.value)

class C2:
    def __init__(self, value):

            

Reported by Pylint.

Missing class docstring
Error

Line: 8 Column: 1

                  def __str__(self):
        return "str<C1 {}>".format(self.value)

class C2:
    def __init__(self, value):
        self.value = value

    def __repr__(self):
        return "repr<C2 {}>".format(self.value)

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 8 Column: 1

                  def __str__(self):
        return "str<C1 {}>".format(self.value)

class C2:
    def __init__(self, value):
        self.value = value

    def __repr__(self):
        return "repr<C2 {}>".format(self.value)

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

                  def __repr__(self):
        return "repr<C2 {}>".format(self.value)

class C3:
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return "str<C3 {}>".format(self.value)

            

Reported by Pylint.

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

Line: 31 Column: 1

              c2 = C2(2)
print(c2)

s11 = str(c1)
print(s11)
# This will use builtin repr(), which uses id(), which is of course different
# between CPython and MicroPython
s12 = repr(c1)
print("C1 object at" in s12)

            

Reported by Pylint.

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

Line: 38 Column: 1

              s12 = repr(c1)
print("C1 object at" in s12)

s21 = str(c2)
print(s21)
s22 = repr(c2)
print(s22)

c3 = C3(1)

            

Reported by Pylint.

tests/cpydiff/core_generator_noexit.py
8 issues
Class 'foo' inherits from object, can be safely removed from bases in python3
Error

Line: 9 Column: 1

              """


class foo(object):
    def __enter__(self):
        print("Enter")

    def __exit__(self, *args):
        print("Exit")

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 9 Column: 1

              """


class foo(object):
    def __enter__(self):
        print("Enter")

    def __exit__(self, *args):
        print("Exit")

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              """


class foo(object):
    def __enter__(self):
        print("Enter")

    def __exit__(self, *args):
        print("Exit")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

                      print("Exit")


def bar(x):
    with foo():
        while True:
            x += 1
            yield x


            

Reported by Pylint.

Black listed name "bar"
Error

Line: 17 Column: 1

                      print("Exit")


def bar(x):
    with foo():
        while True:
            x += 1
            yield x


            

Reported by Pylint.

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

Line: 17 Column: 1

                      print("Exit")


def bar(x):
    with foo():
        while True:
            x += 1
            yield x


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 1

                          yield x


def func():
    g = bar(0)
    for _ in range(3):
        print(next(g))



            

Reported by Pylint.

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

Line: 25 Column: 5

              

def func():
    g = bar(0)
    for _ in range(3):
        print(next(g))


func()

            

Reported by Pylint.