The following issues were found

tests/basics/class_misc.py
4 issues
Missing module docstring
Error

Line: 1 Column: 1

              # converting user instance to buffer
class C:
    pass

c = C()
try:
    d = bytes(c)
except TypeError:
    print('TypeError')

            

Reported by Pylint.

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

Line: 2 Column: 1

              # converting user instance to buffer
class C:
    pass

c = C()
try:
    d = bytes(c)
except TypeError:
    print('TypeError')

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 2 Column: 1

              # converting user instance to buffer
class C:
    pass

c = C()
try:
    d = bytes(c)
except TypeError:
    print('TypeError')

            

Reported by Pylint.

Missing class docstring
Error

Line: 2 Column: 1

              # converting user instance to buffer
class C:
    pass

c = C()
try:
    d = bytes(c)
except TypeError:
    print('TypeError')

            

Reported by Pylint.

tests/basics/builtin_issubclass.py
4 issues
Missing module docstring
Error

Line: 1 Column: 1

              # test builtin issubclass

class A:
    pass

print(issubclass(A, A))
print(issubclass(A, (A,)))

try:

            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              # test builtin issubclass

class A:
    pass

print(issubclass(A, A))
print(issubclass(A, (A,)))

try:

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test builtin issubclass

class A:
    pass

print(issubclass(A, A))
print(issubclass(A, (A,)))

try:

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 3 Column: 1

              # test builtin issubclass

class A:
    pass

print(issubclass(A, A))
print(issubclass(A, (A,)))

try:

            

Reported by Pylint.

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

Line: 7 Column: 5

                  NotImplemented
except NameError:
    print("SKIP")
    raise SystemExit

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


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Test that returning of NotImplemented from binary op methods leads to
# TypeError.
try:
    NotImplemented
except NameError:
    print("SKIP")
    raise SystemExit

class C:

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

                  print("SKIP")
    raise SystemExit

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

    def __str__(self):
        return "C({})".format(self.value)

            

Reported by Pylint.

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

Line: 9 Column: 1

                  print("SKIP")
    raise SystemExit

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

    def __str__(self):
        return "C({})".format(self.value)

            

Reported by Pylint.

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

Line: 10 Column: 9

                      from collections import OrderedDict
    except ImportError:
        print("SKIP")
        raise SystemExit

if not hasattr(int, "__dict__"):
    print("SKIP")
    raise SystemExit


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test using an OrderedDict as the locals to construct a class

try:
    from ucollections import OrderedDict
except ImportError:
    try:
        from collections import OrderedDict
    except ImportError:
        print("SKIP")

            

Reported by Pylint.

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

Line: 17 Column: 1

                  raise SystemExit


A = type("A", (), OrderedDict(a=1, b=2, c=3, d=4, e=5))
print([k for k in A.__dict__.keys() if not k.startswith("_")])

            

Reported by Pylint.

Consider iterating the dictionary directly instead of calling .keys()
Error

Line: 18 Column: 19

              

A = type("A", (), OrderedDict(a=1, b=2, c=3, d=4, e=5))
print([k for k in A.__dict__.keys() if not k.startswith("_")])

            

Reported by Pylint.

tests/basics/builtin_help.py
4 issues
Unable to import 'micropython'
Error

Line: 13 Column: 1

              help(help) # help for a function
help(int) # help for a class
help(1) # help for an instance
import micropython
help(micropython) # help for a module
help('modules') # list available modules

print('done') # so last bit of output is predictable

            

Reported by Pylint.

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

Line: 7 Column: 5

                  help
except NameError:
    print("SKIP")
    raise SystemExit

help() # no args
help(help) # help for a function
help(int) # help for a class
help(1) # help for an instance

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test builtin help function

try:
    help
except NameError:
    print("SKIP")
    raise SystemExit

help() # no args

            

Reported by Pylint.

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

Line: 13 Column: 1

              help(help) # help for a function
help(int) # help for a class
help(1) # help for an instance
import micropython
help(micropython) # help for a module
help('modules') # list available modules

print('done') # so last bit of output is predictable

            

Reported by Pylint.

tests/basics/dict1.py
4 issues
bad operand type for unary +: dict
Error

Line: 62 Column: 5

              
# unsupported unary op
try:
    +{}
except TypeError:
    print('TypeError')

# unsupported binary op
try:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # basic dictionary

d = {}
print(d)
d[2] = 123
print(d)
d = {1:2}
d[3] = 3
print(len(d), d[1], d[3])

            

Reported by Pylint.

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

Line: 14 Column: 1

              print(len(d), d[1], d[3])
print(str(d) == '{1: 0, 3: 3}' or str(d) == '{3: 3, 1: 0}')

x = 1
while x < 100:
    d[x] = x
    x += 1
print(d[50])


            

Reported by Pylint.

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

Line: 57 Column: 1

              # value not found
try:
    {}[0]
except KeyError as er:
    print('KeyError', er, er.args)

# unsupported unary op
try:
    +{}

            

Reported by Pylint.

tests/basics/builtin_hash_intbig.py
4 issues
Missing module docstring
Error

Line: 1 Column: 1

              # test builtin hash function

print({1 << 66:1}) # hash big int
print({-(1 << 66):2}) # hash negative big int

# __hash__ returning a large number should be truncated
class F:
    def __hash__(self):
        return 1 << 70 | 1

            

Reported by Pylint.

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

Line: 7 Column: 1

              print({-(1 << 66):2}) # hash negative big int

# __hash__ returning a large number should be truncated
class F:
    def __hash__(self):
        return 1 << 70 | 1
print(hash(F()) != 0)

# this had a particular error with internal integer arithmetic of hash function

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 7 Column: 1

              print({-(1 << 66):2}) # hash negative big int

# __hash__ returning a large number should be truncated
class F:
    def __hash__(self):
        return 1 << 70 | 1
print(hash(F()) != 0)

# this had a particular error with internal integer arithmetic of hash function

            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              print({-(1 << 66):2}) # hash negative big int

# __hash__ returning a large number should be truncated
class F:
    def __hash__(self):
        return 1 << 70 | 1
print(hash(F()) != 0)

# this had a particular error with internal integer arithmetic of hash function

            

Reported by Pylint.

tests/basics/fun_globals.py
4 issues
Undefined variable 'bar'
Error

Line: 16 Column: 7

              print(foo.__globals__ is globals())

foo.__globals__["bar"] = 123
print(bar)

try:
    foo.__globals__ = None
except AttributeError:
    print("AttributeError")

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test the __globals__ attribute of a function


def foo():
    pass


if not hasattr(foo, "__globals__"):
    print("SKIP")

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 4 Column: 1

              # test the __globals__ attribute of a function


def foo():
    pass


if not hasattr(foo, "__globals__"):
    print("SKIP")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              # test the __globals__ attribute of a function


def foo():
    pass


if not hasattr(foo, "__globals__"):
    print("SKIP")

            

Reported by Pylint.

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

Line: 7 Column: 5

                  eval
except NameError:
    print("SKIP")
    raise SystemExit

try:
    print(eval("[1,,]"))
except SyntaxError:
    print("SyntaxError")

            

Reported by Pylint.

Use of eval
Error

Line: 10 Column: 11

                  raise SystemExit

try:
    print(eval("[1,,]"))
except SyntaxError:
    print("SyntaxError")

            

Reported by Pylint.

Use of possibly insecure function - consider using safer ast.literal_eval.
Security blacklist

Line: 10
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval

                  raise SystemExit

try:
    print(eval("[1,,]"))
except SyntaxError:
    print("SyntaxError")

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              # test if eval raises SyntaxError

try:
    eval
except NameError:
    print("SKIP")
    raise SystemExit

try:

            

Reported by Pylint.

tests/basics/gen_yield_from_exc.py
4 issues
Assigning result of a function call, where the function has no return
Error

Line: 12 Column: 1

                  except ValueError:
        print("caught ValueError from downstream")

g = gen2()
print(list(g))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 1 Column: 1

              def gen():
    yield 1
    yield 2
    raise ValueError

def gen2():
    try:
        print((yield from gen()))
    except ValueError:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              def gen():
    yield 1
    yield 2
    raise ValueError

def gen2():
    try:
        print((yield from gen()))
    except ValueError:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

                  yield 2
    raise ValueError

def gen2():
    try:
        print((yield from gen()))
    except ValueError:
        print("caught ValueError from downstream")


            

Reported by Pylint.