The following issues were found

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

Line: 5 Column: 5

                  str.count
except AttributeError:
    print("SKIP")
    raise SystemExit

print("".count(""))
print("".count("a"))
print("a".count(""))
print("a".count("a"))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    str.count
except AttributeError:
    print("SKIP")
    raise SystemExit

print("".count(""))
print("".count("a"))
print("a".count(""))

            

Reported by Pylint.

Function name "t" doesn't conform to snake_case naming style
Error

Line: 51 Column: 1

              print("aaaa".count('a', -1, 5))
print("abbabba".count("abba"))

def t():
    return True

print("0000".count('0', t()))

try:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 51 Column: 1

              print("aaaa".count('a', -1, 5))
print("abbabba".count("abba"))

def t():
    return True

print("0000".count('0', t()))

try:

            

Reported by Pylint.

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

Line: 1 Column: 1

              a = "a\1b"
print(len(a))
print(ord(a[1]))
print(len("a\123b"))
a = "a\12345b"
print(len(a))
print(ord(a[1]))

a = "a\xffb"

            

Reported by Pylint.

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

Line: 1 Column: 1

              a = "a\1b"
print(len(a))
print(ord(a[1]))
print(len("a\123b"))
a = "a\12345b"
print(len(a))
print(ord(a[1]))

a = "a\xffb"

            

Reported by Pylint.

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

Line: 5 Column: 1

              print(len(a))
print(ord(a[1]))
print(len("a\123b"))
a = "a\12345b"
print(len(a))
print(ord(a[1]))

a = "a\xffb"
print(len(a))

            

Reported by Pylint.

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

Line: 9 Column: 1

              print(len(a))
print(ord(a[1]))

a = "a\xffb"
print(len(a))
print(ord(a[1]))

            

Reported by Pylint.

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

Line: 1 Column: 1

              # test subclassing a native type which can be iterated over

class mymap(map):
    pass

m = mymap(lambda x: x + 10, range(4))
print(list(m))

            

Reported by Pylint.

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

Line: 3 Column: 1

              # test subclassing a native type which can be iterated over

class mymap(map):
    pass

m = mymap(lambda x: x + 10, range(4))
print(list(m))

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 3 Column: 1

              # test subclassing a native type which can be iterated over

class mymap(map):
    pass

m = mymap(lambda x: x + 10, range(4))
print(list(m))

            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              # test subclassing a native type which can be iterated over

class mymap(map):
    pass

m = mymap(lambda x: x + 10, range(4))
print(list(m))

            

Reported by Pylint.

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

Line: 9 Column: 5

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

try:
    exec('return; print("this should not be executed.")')
    # if we get here then MICROPY_CPYTHON_COMPAT is disabled and test
    # should be skipped.

            

Reported by Pylint.

Use of exec
Error

Line: 12 Column: 5

                  raise SystemExit

try:
    exec('return; print("this should not be executed.")')
    # if we get here then MICROPY_CPYTHON_COMPAT is disabled and test
    # should be skipped.
    print("SKIP")
    raise SystemExit
except SyntaxError:

            

Reported by Pylint.

Use of exec detected.
Security

Line: 12
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html

                  raise SystemExit

try:
    exec('return; print("this should not be executed.")')
    # if we get here then MICROPY_CPYTHON_COMPAT is disabled and test
    # should be skipped.
    print("SKIP")
    raise SystemExit
except SyntaxError:

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              # With MICROPY_CPYTHON_COMPAT, the "return" statement can only appear in a
# function.
# Otherwise (in minimal builds), it ends execution of a module/class.

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

            

Reported by Pylint.

tests/basics/true_value.py
4 issues
Using a conditional statement with a constant value
Error

Line: 14 Column: 1

              
if not "":
    print("Empty string")
if "foo":
    print("Non-empty string")

if not ():
    print("Empty tuple")
if ("",):

            

Reported by Pylint.

Using a conditional statement with a constant value
Error

Line: 19 Column: 1

              
if not ():
    print("Empty tuple")
if ("",):
    print("Non-empty tuple")

if not []:
    print("Empty list")
if [0]:

            

Reported by Pylint.

Using a conditional statement with a constant value
Error

Line: 29 Column: 1

              
if not {}:
    print("Empty dict")
if {0:0}:
    print("Non-empty dict")

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Test true-ish value handling

if not False:
    print("False")

if not None:
    print("None")

if not 0:

            

Reported by Pylint.

tests/basics/try1.py
4 issues
Instance of 'int' has no 'a' member
Error

Line: 4 Column: 5

              # basic exceptions
x = 1
try:
    x.a()
except:
    print(x)

try:
    raise IndexError

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 5 Column: 1

              x = 1
try:
    x.a()
except:
    print(x)

try:
    raise IndexError
except IndexError:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # basic exceptions
x = 1
try:
    x.a()
except:
    print(x)

try:
    raise IndexError

            

Reported by Pylint.

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

Line: 2 Column: 1

              # basic exceptions
x = 1
try:
    x.a()
except:
    print(x)

try:
    raise IndexError

            

Reported by Pylint.

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

Line: 18 Column: 13

                      try:
            value = next(self._it)
        except StopIteration:
            raise StopAsyncIteration
        return value

async def coro():
    async for letter in AsyncIteratorWrapper('abc'):
        print(letter)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test basic async for execution
# example taken from PEP0492

class AsyncIteratorWrapper:
    def __init__(self, obj):
        print('init')
        self._it = iter(obj)

    def __aiter__(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              # test basic async for execution
# example taken from PEP0492

class AsyncIteratorWrapper:
    def __init__(self, obj):
        print('init')
        self._it = iter(obj)

    def __aiter__(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 1

                          raise StopAsyncIteration
        return value

async def coro():
    async for letter in AsyncIteratorWrapper('abc'):
        print(letter)

o = coro()
try:

            

Reported by Pylint.

tests/basics/assign_expr_syntaxerror.py
4 issues
Use of eval
Error

Line: 5 Column: 15

              
def test(code):
    try:
        print(eval(code))
    except SyntaxError:
        print('SyntaxError')

test("x := 1")
test("((x, y) := 1)")

            

Reported by Pylint.

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

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

              
def test(code):
    try:
        print(eval(code))
    except SyntaxError:
        print('SyntaxError')

test("x := 1")
test("((x, y) := 1)")

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              # test SyntaxError with := operator

def test(code):
    try:
        print(eval(code))
    except SyntaxError:
        print('SyntaxError')

test("x := 1")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # test SyntaxError with := operator

def test(code):
    try:
        print(eval(code))
    except SyntaxError:
        print('SyntaxError')

test("x := 1")

            

Reported by Pylint.

tests/basics/while_cond.py
4 issues
Else clause on loop without a break statement
Error

Line: 5 Column: 1

              
while 0:
    print(0)
else:
    print(1)

while 1:
    print(2)
    break

            

Reported by Pylint.

Else clause on loop without a break statement
Error

Line: 22 Column: 1

              
while False:
    print('a')
else:
    print('b')

while True:
    print('a')
    break

            

Reported by Pylint.

Else clause on loop without a break statement
Error

Line: 35 Column: 1

              
while not True:
    print('a')
else:
    print('b')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # test while conditions which are optimised by the compiler

while 0:
    print(0)
else:
    print(1)

while 1:
    print(2)

            

Reported by Pylint.

tests/cpydiff/modules/foo.py
4 issues
Undefined variable 'xxx'
Error

Line: 2 Column: 1

              print("foo")
xxx

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 2 Column: 1

              print("foo")
xxx

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              print("foo")
xxx

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 1 Column: 1

              print("foo")
xxx

            

Reported by Pylint.