The following issues were found

Lib/ast.py
339 issues
class already defined line 28
Error

Line: 595 Column: 1

                  type(...): 'Ellipsis',
}

class slice(AST):
    """Deprecated AST node class."""

class Index(slice):
    """Deprecated AST node class. Use the index value directly instead."""
    def __new__(cls, value, **kwargs):

            

Reported by Pylint.

class already defined line 28
Error

Line: 598 Column: 1

              class slice(AST):
    """Deprecated AST node class."""

class Index(slice):
    """Deprecated AST node class. Use the index value directly instead."""
    def __new__(cls, value, **kwargs):
        return value

class ExtSlice(slice):

            

Reported by Pylint.

class already defined line 28
Error

Line: 603 Column: 1

                  def __new__(cls, value, **kwargs):
        return value

class ExtSlice(slice):
    """Deprecated AST node class. Use ast.Tuple instead."""
    def __new__(cls, dims=(), **kwargs):
        return Tuple(list(dims), Load(), **kwargs)

# If the ast module is loaded more than once, only add deprecated methods once

            

Reported by Pylint.

class already defined line 28
Error

Line: 622 Column: 1

              
    Tuple.dims = property(_dims_getter, _dims_setter)

class Suite(mod):
    """Deprecated AST node class.  Unused in Python 3."""

class AugLoad(expr_context):
    """Deprecated AST node class.  Unused in Python 3."""


            

Reported by Pylint.

class already defined line 28
Error

Line: 625 Column: 1

              class Suite(mod):
    """Deprecated AST node class.  Unused in Python 3."""

class AugLoad(expr_context):
    """Deprecated AST node class.  Unused in Python 3."""

class AugStore(expr_context):
    """Deprecated AST node class.  Unused in Python 3."""


            

Reported by Pylint.

class already defined line 28
Error

Line: 628 Column: 1

              class AugLoad(expr_context):
    """Deprecated AST node class.  Unused in Python 3."""

class AugStore(expr_context):
    """Deprecated AST node class.  Unused in Python 3."""

class Param(expr_context):
    """Deprecated AST node class.  Unused in Python 3."""


            

Reported by Pylint.

class already defined line 28
Error

Line: 631 Column: 1

              class AugStore(expr_context):
    """Deprecated AST node class.  Unused in Python 3."""

class Param(expr_context):
    """Deprecated AST node class.  Unused in Python 3."""


# Large float and imaginary literals get turned into infinities in the AST.
# We unparse those infinities to INFSTR.

            

Reported by Pylint.

_Precedence.TEST.next is not callable
Error

Line: 1181 Column: 37

                  def visit_FormattedValue(self, node):
        def unparse_inner(inner):
            unparser = type(self)(_avoid_backslashes=True)
            unparser.set_precedence(_Precedence.TEST.next(), inner)
            return unparser.visit(inner)

        with self.delimit("{", "}"):
            expr = unparse_inner(node.value)
            if "\\" in expr:

            

Reported by Pylint.

_Precedence.TEST.next is not callable
Error

Line: 1273 Column: 29

                      self.set_precedence(_Precedence.TUPLE, node.target)
        self.traverse(node.target)
        self.write(" in ")
        self.set_precedence(_Precedence.TEST.next(), node.iter, *node.ifs)
        self.traverse(node.iter)
        for if_clause in node.ifs:
            self.write(" if ")
            self.traverse(if_clause)


            

Reported by Pylint.

_Precedence.TEST.next is not callable
Error

Line: 1281 Column: 33

              
    def visit_IfExp(self, node):
        with self.require_parens(_Precedence.TEST, node):
            self.set_precedence(_Precedence.TEST.next(), node.body, node.test)
            self.traverse(node.body)
            self.write(" if ")
            self.traverse(node.test)
            self.write(" else ")
            self.set_precedence(_Precedence.TEST, node.orelse)

            

Reported by Pylint.

Lib/ctypes/test/test_structures.py
338 issues
class already defined line 140
Error

Line: 154 Column: 9

                      self.assertRaises((TypeError, AttributeError), setattr, X.x, "offset", 92)
        self.assertRaises((TypeError, AttributeError), setattr, X.x, "size", 92)

        class X(Union):
            _fields_ = [("x", c_int),
                        ("y", c_char)]

        self.assertEqual(X.x.offset, 0)
        self.assertEqual(X.x.size, sizeof(c_int))

            

Reported by Pylint.

class already defined line 172
Error

Line: 180 Column: 9

                      self.assertEqual(sizeof(X), 9)
        self.assertEqual(X.b.offset, 1)

        class X(Structure):
            _fields_ = [("a", c_byte),
                        ("b", c_longlong)]
            _pack_ = 2
        self.assertEqual(sizeof(X), 10)
        self.assertEqual(X.b.offset, 2)

            

Reported by Pylint.

class already defined line 172
Error

Line: 191 Column: 9

                      longlong_size = struct.calcsize("q")
        longlong_align = struct.calcsize("bq") - longlong_size

        class X(Structure):
            _fields_ = [("a", c_byte),
                        ("b", c_longlong)]
            _pack_ = 4
        self.assertEqual(sizeof(X), min(4, longlong_align) + longlong_size)
        self.assertEqual(X.b.offset, min(4, longlong_align))

            

Reported by Pylint.

class already defined line 172
Error

Line: 198 Column: 9

                      self.assertEqual(sizeof(X), min(4, longlong_align) + longlong_size)
        self.assertEqual(X.b.offset, min(4, longlong_align))

        class X(Structure):
            _fields_ = [("a", c_byte),
                        ("b", c_longlong)]
            _pack_ = 8

        self.assertEqual(sizeof(X), min(8, longlong_align) + longlong_size)

            

Reported by Pylint.

Unused import RTLD_LOCAL from wildcard import
Error

Line: 4 Column: 1

              import platform
import sys
import unittest
from ctypes import *
from ctypes.test import need_symbol
from struct import calcsize
import _ctypes_test
from test import support


            

Reported by Pylint.

Unused import Array from wildcard import
Error

Line: 4 Column: 1

              import platform
import sys
import unittest
from ctypes import *
from ctypes.test import need_symbol
from struct import calcsize
import _ctypes_test
from test import support


            

Reported by Pylint.

Unused import c_uint64 from wildcard import
Error

Line: 4 Column: 1

              import platform
import sys
import unittest
from ctypes import *
from ctypes.test import need_symbol
from struct import calcsize
import _ctypes_test
from test import support


            

Reported by Pylint.

Unused import c_int64 from wildcard import
Error

Line: 4 Column: 1

              import platform
import sys
import unittest
from ctypes import *
from ctypes.test import need_symbol
from struct import calcsize
import _ctypes_test
from test import support


            

Reported by Pylint.

Unused import c_int32 from wildcard import
Error

Line: 4 Column: 1

              import platform
import sys
import unittest
from ctypes import *
from ctypes.test import need_symbol
from struct import calcsize
import _ctypes_test
from test import support


            

Reported by Pylint.

Unused import c_int16 from wildcard import
Error

Line: 4 Column: 1

              import platform
import sys
import unittest
from ctypes import *
from ctypes.test import need_symbol
from struct import calcsize
import _ctypes_test
from test import support


            

Reported by Pylint.

Lib/test/test_deque.py
329 issues
Module 'sys' has no 'gettotalrefcount' member
Error

Line: 1054 Column: 25

                      for i in range(len(counts)):
            support.run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print(counts)

    # doctests
    from test import test_deque
    support.run_doctest(test_deque, verbose)

            

Reported by Pylint.

Unreachable code
Error

Line: 15 Column: 5

              
def fail():
    raise SyntaxError
    yield 1

class BadCmp:
    def __eq__(self, other):
        raise RuntimeError


            

Reported by Pylint.

Redefining name 'deque' from outer scope (line 1)
Error

Line: 22 Column: 24

                      raise RuntimeError

class MutateCmp:
    def __init__(self, deque, result):
        self.deque = deque
        self.result = result
    def __eq__(self, other):
        self.deque.clear()
        return self.result

            

Reported by Pylint.

Attribute 'd' defined outside __init__
Error

Line: 119 Column: 9

                              return True
        m = MutatingCompare()
        d = deque([1, 2, 3, m, 4, 5])
        m.d = d
        self.assertRaises(RuntimeError, d.count, 3)

        # test issue11004
        # block advance failed after rotation aligned elements on right side of block
        d = deque([None]*16)

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 125 Column: 13

                      # test issue11004
        # block advance failed after rotation aligned elements on right side of block
        d = deque([None]*16)
        for i in range(len(d)):
            d.rotate(-1)
        d.rotate(1)
        self.assertEqual(d.count(1), 0)
        self.assertEqual(d.count(None), 16)


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 160 Column: 13

                      d = deque(range(n))
        d[n//2] = MutateCmp(d, False)
        with self.assertRaises(RuntimeError):
            n in d

        # Test detection of comparison exceptions
        d = deque(range(n))
        d[n//2] = BadCmp()
        with self.assertRaises(RuntimeError):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 166 Column: 13

                      d = deque(range(n))
        d[n//2] = BadCmp()
        with self.assertRaises(RuntimeError):
            n in d

    def test_contains_count_stop_crashes(self):
        class A:
            def __eq__(self, other):
                d.clear()

            

Reported by Pylint.

Expression "deque('abc') + 'def'" is assigned to nothing
Error

Line: 206 Column: 13

                      self.assertEqual(g + h, deque('efgh'))

        with self.assertRaises(TypeError):
            deque('abc') + 'def'

    def test_iadd(self):
        d = deque('a')
        d += 'bcd'
        self.assertEqual(list(d), list('abcd'))

            

Reported by Pylint.

Unused variable 'nonelement'
Error

Line: 271 Column: 9

              
        # Test start and stop arguments behavior matches list.index()
        elements = 'ABCDEFGHI'
        nonelement = 'Z'
        d = deque(elements * 2)
        s = list(elements * 2)
        for start in range(-5 - len(s)*2, 5 + len(s) * 2):
            for stop in range(-5 - len(s)*2, 5 + len(s) * 2):
                for element in elements + 'Z':

            

Reported by Pylint.

Unused variable 'step'
Error

Line: 287 Column: 13

              
        # Test large start argument
        d = deque(range(0, 10000, 10))
        for step in range(100):
            i = d.index(8500, 700)
            self.assertEqual(d[i], 8500)
            # Repeat test with a different internal offset
            d.rotate()


            

Reported by Pylint.

Lib/test/test_httplib.py
329 issues
No value for argument 'text' in constructor call
Error

Line: 134 Column: 16

                      return super().connect()

    def create_connection(self, *pos, **kw):
        return FakeSocket(*self.fake_socket_args)

class HeaderTests(TestCase):
    def test_auto_headers(self):
        # Some headers are added automatically, but should not be added by
        # .request() if they are explicitly set.

            

Reported by Pylint.

Unused argument 'bufsize'
Error

Line: 69 Column: 30

                      self.sendall_calls += 1
        self.data += data

    def makefile(self, mode, bufsize=None):
        if mode != 'r' and mode != 'rb':
            raise client.UnimplementedFileMode()
        # keep the file around so we can check how much was read from it
        self.file = self.fileclass(self.text)
        self.file.close = self.file_close #nerf close ()

            

Reported by Pylint.

Attribute 'file' defined outside __init__
Error

Line: 73 Column: 9

                      if mode != 'r' and mode != 'rb':
            raise client.UnimplementedFileMode()
        # keep the file around so we can check how much was read from it
        self.file = self.fileclass(self.text)
        self.file.close = self.file_close #nerf close ()
        return self.file

    def file_close(self):
        self.file_closed = True

            

Reported by Pylint.

Unused argument 'pos'
Error

Line: 133 Column: 1

                      self.connections += 1
        return super().connect()

    def create_connection(self, *pos, **kw):
        return FakeSocket(*self.fake_socket_args)

class HeaderTests(TestCase):
    def test_auto_headers(self):
        # Some headers are added automatically, but should not be added by

            

Reported by Pylint.

Unused argument 'kw'
Error

Line: 133 Column: 1

                      self.connections += 1
        return super().connect()

    def create_connection(self, *pos, **kw):
        return FakeSocket(*self.fake_socket_args)

class HeaderTests(TestCase):
    def test_auto_headers(self):
        # Some headers are added automatically, but should not be added by

            

Reported by Pylint.

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

Line: 142 Column: 13

                      # .request() if they are explicitly set.

        class HeaderCountingBuffer(list):
            def __init__(self):
                self.count = {}
            def append(self, item):
                kv = item.split(b':')
                if len(kv) > 1:
                    # item is a 'Key: Value' header string

            

Reported by Pylint.

Access to a protected member _buffer of a client class
Error

Line: 157 Column: 17

                          for header in 'Content-length', 'Host', 'Accept-encoding':
                conn = client.HTTPConnection('example.com')
                conn.sock = FakeSocket('blahblahblah')
                conn._buffer = HeaderCountingBuffer()

                body = 'spamspamspam'
                headers = {}
                if explicit_header:
                    headers[header] = str(len(body))

            

Reported by Pylint.

Access to a protected member _buffer of a client class
Error

Line: 164 Column: 34

                              if explicit_header:
                    headers[header] = str(len(body))
                conn.request('POST', '/', body, headers)
                self.assertEqual(conn._buffer.count[header.lower()], 1)

    def test_content_length_0(self):

        class ContentLengthChecker(list):
            def __init__(self):

            

Reported by Pylint.

Access to a protected member _buffer of a client class
Error

Line: 185 Column: 13

                      for method, body in itertools.product(methods_with_body, bodies):
            conn = client.HTTPConnection('example.com')
            conn.sock = FakeSocket(None)
            conn._buffer = ContentLengthChecker()
            conn.request(method, '/', body)
            self.assertEqual(
                conn._buffer.content_length, b'0',
                'Header Content-Length incorrect on {}'.format(method)
            )

            

Reported by Pylint.

Access to a protected member _buffer of a client class
Error

Line: 188 Column: 17

                          conn._buffer = ContentLengthChecker()
            conn.request(method, '/', body)
            self.assertEqual(
                conn._buffer.content_length, b'0',
                'Header Content-Length incorrect on {}'.format(method)
            )

        # For these methods, we make sure that content-length is not set when
        # the body is None because it might cause unexpected behaviour on the

            

Reported by Pylint.

Lib/idlelib/editor.py
328 issues
Cannot import 'traceback' due to syntax error 'invalid syntax (<unknown>, line 576)'
Error

Line: 9 Column: 1

              import string
import sys
import tokenize
import traceback
import webbrowser

from tkinter import *
from tkinter.font import Font
from tkinter.ttk import Scrollbar

            

Reported by Pylint.

Module 'os' has no 'startfile' member
Error

Line: 599 Column: 17

                  def python_docs(self, event=None):
        if sys.platform[:3] == 'win':
            try:
                os.startfile(self.help_url)
            except OSError as why:
                messagebox.showerror(title='Document Start Failure',
                    message=str(why), parent=self.text)
        else:
            webbrowser.open(self.help_url)

            

Reported by Pylint.

An attribute defined in editor line 771 hides this method
Error

Line: 765 Column: 5

                      line = self.text.get('1.0', '1.0 lineend')
        return line.startswith('#!') and 'python' in line

    def close_hook(self):
        if self.flist:
            self.flist.unregister_maybe_terminate(self)
            self.flist = None

    def set_close_hook(self, close_hook):

            

Reported by Pylint.

Module 'os' has no 'startfile' member
Error

Line: 928 Column: 21

                              helpfile = os.path.normpath(helpfile)
            if sys.platform[:3] == 'win':
                try:
                    os.startfile(helpfile)
                except OSError as why:
                    messagebox.showerror(title='Document Start Failure',
                        message=str(why), parent=self.text)
            else:
                webbrowser.open(helpfile)

            

Reported by Pylint.

Unused import MOVETO from wildcard import
Error

Line: 12 Column: 1

              import traceback
import webbrowser

from tkinter import *
from tkinter.font import Font
from tkinter.ttk import Scrollbar
from tkinter import simpledialog
from tkinter import messagebox


            

Reported by Pylint.

Unused import MITER from wildcard import
Error

Line: 12 Column: 1

              import traceback
import webbrowser

from tkinter import *
from tkinter.font import Font
from tkinter.ttk import Scrollbar
from tkinter import simpledialog
from tkinter import messagebox


            

Reported by Pylint.

Wildcard import tkinter
Error

Line: 12 Column: 1

              import traceback
import webbrowser

from tkinter import *
from tkinter.font import Font
from tkinter.ttk import Scrollbar
from tkinter import simpledialog
from tkinter import messagebox


            

Reported by Pylint.

Unused import BEVEL from wildcard import
Error

Line: 12 Column: 1

              import traceback
import webbrowser

from tkinter import *
from tkinter.font import Font
from tkinter.ttk import Scrollbar
from tkinter import simpledialog
from tkinter import messagebox


            

Reported by Pylint.

Unused import ROUND from wildcard import
Error

Line: 12 Column: 1

              import traceback
import webbrowser

from tkinter import *
from tkinter.font import Font
from tkinter.ttk import Scrollbar
from tkinter import simpledialog
from tkinter import messagebox


            

Reported by Pylint.

Unused import PROJECTING from wildcard import
Error

Line: 12 Column: 1

              import traceback
import webbrowser

from tkinter import *
from tkinter.font import Font
from tkinter.ttk import Scrollbar
from tkinter import simpledialog
from tkinter import messagebox


            

Reported by Pylint.

Lib/test/test_scope.py
324 issues
Using variable 'y' before assignment
Error

Line: 307 Column: 19

                  def testUnboundLocal(self):

        def errorInOuter():
            print(y)
            def inner():
                return y
            y = 1

        def errorInInner():

            

Reported by Pylint.

function already defined line 530
Error

Line: 540 Column: 9

              
        self.assertEqual(f(1).x, 12)

        def f(x):
            class C:
                y = x
                def m(self):
                    return x
                z = list(locals())

            

Reported by Pylint.

Undefined variable 'nestedcell_get'
Error

Line: 654 Column: 17

                      # the cell where the object was stored.
        class Special:
            def __del__(self):
                nestedcell_get()

    def testNonLocalFunction(self):

        def f(x):
            def inc():

            

Reported by Pylint.

class already defined line 772
Error

Line: 776 Column: 9

                          locals()["x"] = 43
            y = x
        self.assertEqual(X.y, 43)
        class X:
            locals()["x"] = 43
            del x
        self.assertFalse(hasattr(X, "x"))
        self.assertEqual(x, 42)


            

Reported by Pylint.

Undefined variable 'x'
Error

Line: 778 Column: 17

                      self.assertEqual(X.y, 43)
        class X:
            locals()["x"] = 43
            del x
        self.assertFalse(hasattr(X, "x"))
        self.assertEqual(x, 42)

    @cpython_only
    def testCellLeak(self):

            

Reported by Pylint.

XXX add exta level of indirection
Error

Line: 53 Column: 3

              
    def testNestingGlobalNoFree(self):

        def make_adder4(): # XXX add exta level of indirection
            def nest():
                def nest():
                    def adder(y):
                        return global_x + y # check that plain old globals work
                    return adder

            

Reported by Pylint.

Global variable 'global_nest_x' undefined at the module level
Error

Line: 86 Column: 13

                  def testNestingPlusFreeRefToGlobal(self):

        def make_adder6(x):
            global global_nest_x
            def adder(y):
                return global_nest_x + y
            global_nest_x = x
            return adder


            

Reported by Pylint.

Unused argument 'x'
Error

Line: 100 Column: 15

              
    def testNearestEnclosingScope(self):

        def f(x):
            def g(y):
                x = 42 # check that this masks binding in f()
                def h(z):
                    return x + z
                return h

            

Reported by Pylint.

Unused argument 'y'
Error

Line: 101 Column: 19

                  def testNearestEnclosingScope(self):

        def f(x):
            def g(y):
                x = 42 # check that this masks binding in f()
                def h(z):
                    return x + z
                return h
            return g(2)

            

Reported by Pylint.

Unused argument 'y'
Error

Line: 116 Column: 18

                      def identity(x):
            return x

        def f(x, y, z):
            def g(a, b, c):
                a = a + x # 3
                def h():
                    # z * (4 + 9)
                    # 3 * 13

            

Reported by Pylint.

Tools/demo/spreadsheet.py
322 issues
No value for argument 'y2' in method call
Error

Line: 131 Column: 9

                  def deletecolumns(self, x1, x2):
        if x1 > x2:
            x1, x2 = x2, x1
        self.clearcells(x1, x2)
        self.movecells(x2+1, 0, sys.maxsize, sys.maxsize, x1-x2-1, 0)

    def getsize(self):
        maxx = maxy = 0
        for x, y in self.cells:

            

Reported by Pylint.

No value for argument 'x2' in method call
Error

Line: 131 Column: 9

                  def deletecolumns(self, x1, x2):
        if x1 > x2:
            x1, x2 = x2, x1
        self.clearcells(x1, x2)
        self.movecells(x2+1, 0, sys.maxsize, sys.maxsize, x1-x2-1, 0)

    def getsize(self):
        maxx = maxy = 0
        for x, y in self.cells:

            

Reported by Pylint.

Unable to import 'tkinter'
Error

Line: 473 Column: 1

                      s = chr(m+ord('A')) + s
    return s

import tkinter as Tk

class SheetGUI:

    """Beginnings of a GUI for a spreadsheet.


            

Reported by Pylint.

Redefining built-in 'sum'
Error

Line: 28 Column: 1

              
align2anchor = {LEFT: "w", CENTER: "center", RIGHT: "e"}

def sum(seq):
    total = 0
    for x in seq:
        if x is not None:
            total += x
    return total

            

Reported by Pylint.

Attribute 'texts' defined outside __init__
Error

Line: 241 Column: 9

                      method = getattr(self, 'start_'+tag, None)
        if method:
            method(attrs)
        self.texts = []

    def data(self, text):
        self.texts.append(text)

    def endelement(self, tag):

            

Reported by Pylint.

Attribute 'y' defined outside __init__
Error

Line: 252 Column: 9

                          method("".join(self.texts))

    def start_cell(self, attrs):
        self.y = int(attrs.get("row"))
        self.x = int(attrs.get("col"))

    def start_value(self, attrs):
        self.fmt = attrs.get('format')
        self.alignment = xml2align.get(attrs.get('align'))

            

Reported by Pylint.

Attribute 'x' defined outside __init__
Error

Line: 253 Column: 9

              
    def start_cell(self, attrs):
        self.y = int(attrs.get("row"))
        self.x = int(attrs.get("col"))

    def start_value(self, attrs):
        self.fmt = attrs.get('format')
        self.alignment = xml2align.get(attrs.get('align'))


            

Reported by Pylint.

Attribute 'fmt' defined outside __init__
Error

Line: 256 Column: 9

                      self.x = int(attrs.get("col"))

    def start_value(self, attrs):
        self.fmt = attrs.get('format')
        self.alignment = xml2align.get(attrs.get('align'))

    start_formula = start_value

    def end_int(self, text):

            

Reported by Pylint.

Attribute 'alignment' defined outside __init__
Error

Line: 257 Column: 9

              
    def start_value(self, attrs):
        self.fmt = attrs.get('format')
        self.alignment = xml2align.get(attrs.get('align'))

    start_formula = start_value

    def end_int(self, text):
        try:

            

Reported by Pylint.

Attribute 'value' defined outside __init__
Error

Line: 263 Column: 13

              
    def end_int(self, text):
        try:
            self.value = int(text)
        except (TypeError, ValueError):
            self.value = None

    end_long = end_int


            

Reported by Pylint.

Lib/unittest/test/testmock/testhelpers.py
322 issues
Method should have "self" as first argument
Error

Line: 874 Column: 13

              
    def test_autospec_functions_with_self_in_odd_place(self):
        class Foo(object):
            def f(a, self): pass

        a = create_autospec(Foo)
        a.f(10)
        a.f.assert_called_with(10)
        a.f.assert_called_with(self=10)

            

Reported by Pylint.

meth is not callable
Error

Line: 931 Column: 31

              
    def test_autospec_on_bound_builtin_function(self):
        meth = types.MethodType(time.ctime, time.time())
        self.assertIsInstance(meth(), str)
        mocked = create_autospec(meth)

        # no signature, so no spec to check against
        mocked()
        mocked.assert_called_once_with()

            

Reported by Pylint.

Unused argument 'a'
Error

Line: 452 Column: 17

              

    def test_create_autospec_keyword_only_arguments(self):
        def foo(a, *, b=None): pass

        m = create_autospec(foo)
        m(1)
        m.assert_called_with(1)
        self.assertRaises(TypeError, m, 1, 2)

            

Reported by Pylint.

Unused argument 'b'
Error

Line: 452 Column: 23

              

    def test_create_autospec_keyword_only_arguments(self):
        def foo(a, *, b=None): pass

        m = create_autospec(foo)
        m(1)
        m.assert_called_with(1)
        self.assertRaises(TypeError, m, 1, 2)

            

Reported by Pylint.

Unused argument 'a'
Error

Line: 465 Column: 15

              
    def test_function_as_instance_attribute(self):
        obj = SomeClass()
        def f(a): pass
        obj.f = f

        mock = create_autospec(obj)
        mock.f('bing')
        mock.f.assert_called_with('bing')

            

Reported by Pylint.

Attribute 'f' defined outside __init__
Error

Line: 466 Column: 9

                  def test_function_as_instance_attribute(self):
        obj = SomeClass()
        def f(a): pass
        obj.f = f

        mock = create_autospec(obj)
        mock.f('bing')
        mock.f.assert_called_with('bing')


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 535 Column: 13

              
        inst = CrazyClass()
        with self.assertRaises(AttributeError):
            inst.other
        self.assertEqual(inst.crazy(42), 42)

        mock = create_autospec(inst)
        mock.crazy(42)
        with self.assertRaises(TypeError):

            

Reported by Pylint.

Unused argument 'b'
Error

Line: 748 Column: 18

              

    def test_function(self):
        def f(a, b): pass

        mock = create_autospec(f)
        self.assertRaises(TypeError, mock)
        mock(1, 2)
        mock.assert_called_with(1, 2)

            

Reported by Pylint.

Unused argument 'a'
Error

Line: 748 Column: 15

              

    def test_function(self):
        def f(a, b): pass

        mock = create_autospec(f)
        self.assertRaises(TypeError, mock)
        mock(1, 2)
        mock.assert_called_with(1, 2)

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 767 Column: 36

              
    def test_skip_attributeerrors(self):
        class Raiser(object):
            def __get__(self, obj, type=None):
                if obj is None:
                    raise AttributeError('Can only be accessed via an instance')

        class RaiserClass(object):
            raiser = Raiser()

            

Reported by Pylint.

Lib/test/test_sys.py
321 issues
Module 'builtins' has no '_' member
Error

Line: 36 Column: 26

                          dh(42)

        self.assertEqual(out.getvalue(), "42\n")
        self.assertEqual(builtins._, 42)

        del builtins._

        with support.captured_stdout() as out:
            dh(None)

            

Reported by Pylint.

Module 'builtins' has no '_' member
Error

Line: 38 Column: 13

                      self.assertEqual(out.getvalue(), "42\n")
        self.assertEqual(builtins._, 42)

        del builtins._

        with support.captured_stdout() as out:
            dh(None)

        self.assertEqual(out.getvalue(), "")

            

Reported by Pylint.

No name 'get_recursion_depth' in module '_testinternalcapi'
Error

Line: 247 Column: 9

                      # Issue #25274: Setting a low recursion limit must be blocked if the
        # current recursion depth is already higher than limit.

        from _testinternalcapi import get_recursion_depth

        def set_recursion_limit_at_depth(depth, limit):
            recursion_depth = get_recursion_depth()
            if recursion_depth >= depth:
                with self.assertRaises(RecursionError) as cm:

            

Reported by Pylint.

Module 'sys' has no 'getwindowsversion' member
Error

Line: 273 Column: 13

                  def test_getwindowsversion(self):
        # Raise SkipTest if sys doesn't have getwindowsversion attribute
        test.support.get_attribute(sys, "getwindowsversion")
        v = sys.getwindowsversion()
        self.assertEqual(len(v), 5)
        self.assertIsInstance(v[0], int)
        self.assertIsInstance(v[1], int)
        self.assertIsInstance(v[2], int)
        self.assertIsInstance(v[3], int)

            

Reported by Pylint.

Module 'sys' has no 'getwindowsversion' member
Error

Line: 298 Column: 40

              
        # This is how platform.py calls it. Make sure tuple
        #  still has 5 elements
        maj, min, buildno, plat, csd = sys.getwindowsversion()

    def test_call_tracing(self):
        self.assertRaises(TypeError, sys.call_tracing, type, 2)

    @unittest.skipUnless(hasattr(sys, "setdlopenflags"),

            

Reported by Pylint.

Module 'sys' has no 'gettotalrefcount' member
Error

Line: 328 Column: 35

                      del n
        self.assertEqual(sys.getrefcount(None), c)
        if hasattr(sys, "gettotalrefcount"):
            self.assertIsInstance(sys.gettotalrefcount(), int)

    def test_getframe(self):
        self.assertRaises(TypeError, sys._getframe, 42, 42)
        self.assertRaises(ValueError, sys._getframe, 2000000000)
        self.assertTrue(

            

Reported by Pylint.

Cannot import 'traceback' due to syntax error 'invalid syntax (<unknown>, line 576)'
Error

Line: 342 Column: 1

                  @threading_helper.reap_threads
    def test_current_frames(self):
        import threading
        import traceback

        # Spawn a thread that blocks at a known place.  Then the main
        # thread does sys._current_frames(), and verifies that the frames
        # returned make sense.
        entered_g = threading.Event()

            

Reported by Pylint.

Cannot import 'traceback' due to syntax error 'invalid syntax (<unknown>, line 576)'
Error

Line: 407 Column: 1

                  @threading_helper.reap_threads
    def test_current_exceptions(self):
        import threading
        import traceback

        # Spawn a thread that blocks at a known place.  Then the main
        # thread does sys._current_frames(), and verifies that the frames
        # returned make sense.
        entered_g = threading.Event()

            

Reported by Pylint.

Module 'sys' has no '_current_exceptions' member
Error

Line: 439 Column: 13

                      self.assertEqual(len(thread_info), 1)
        thread_id = thread_info[0]

        d = sys._current_exceptions()
        for tid in d:
            self.assertIsInstance(tid, int)
            self.assertGreater(tid, 0)

        main_id = threading.get_ident()

            

Reported by Pylint.

Module 'sys' has no 'orig_argv' member
Error

Line: 476 Column: 31

                      self.assertIsInstance(sys.argv, list)
        for arg in sys.argv:
            self.assertIsInstance(arg, str)
        self.assertIsInstance(sys.orig_argv, list)
        for arg in sys.orig_argv:
            self.assertIsInstance(arg, str)
        self.assertIn(sys.byteorder, ("little", "big"))
        self.assertIsInstance(sys.builtin_module_names, tuple)
        self.assertIsInstance(sys.copyright, str)

            

Reported by Pylint.

Parser/asdl_c.py
317 issues
Unused import os
Error

Line: 4 Column: 1

              #! /usr/bin/env python
"""Generate C code from an ASDL description."""

import os
import sys
import textwrap
import types

from argparse import ArgumentParser

            

Reported by Pylint.

XXX this should be fixed for real
Error

Line: 48 Column: 3

                  padding = ""
    while len(cur) > size:
        i = cur.rfind(' ', 0, size)
        # XXX this should be fixed for real
        if i == -1 and 'GeneratorExp' in cur:
            i = size + 3
        assert i != -1, "Impossible line %d to reflow: %r" % (size, s)
        lines.append(padding + cur[:i])
        if len(lines) == 1:

            

Reported by Pylint.

Else clause on loop without a break statement
Error

Line: 67 Column: 5

                                  size -= j
                    padding = " " * j
        cur = cur[i+1:]
    else:
        lines.append(padding + cur)
    return lines

def reflow_c_string(s, depth):
    return '"%s"' % s.replace('\n', '\\n"\n%s"' % (' ' * depth * TABSIZE))

            

Reported by Pylint.

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

Line: 97 Column: 13

                      return "{}{}".format(name, fields)
    else:
        if is_simple(obj):
            types = " | ".join(type.name for type in obj.types)
        else:
            sep = "\n{}| ".format(" " * (len(name) + 1))
            types = sep.join(
                asdl_of(type.name, type) for type in obj.types
            )

            

Reported by Pylint.

XXX reflow long lines?
Error

Line: 114 Column: 3

                      super(EmitVisitor, self).__init__()

    def emit(self, s, depth, reflow=True):
        # XXX reflow long lines?
        if reflow:
            lines = reflow_lines(s, depth)
        else:
            lines = [s]
        for line in lines:

            

Reported by Pylint.

Redefining name 'args' from outer scope (line 1643)
Error

Line: 140 Column: 1

              class MetadataVisitor(asdl.VisitorBase):
    ROOT_TYPE = "AST"

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Metadata:
        #    - simple_sums: Tracks the list of compound type
        #                   names where all the constructors

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 164 Column: 25

                      for dfn in mod.dfns:
            self.visit(dfn)

    def visitType(self, type):
        self.visit(type.value, type.name)

    def visitSum(self, sum, name):
        self.metadata.types.add(name)


            

Reported by Pylint.

Redefining built-in 'sum'
Error

Line: 167 Column: 24

                  def visitType(self, type):
        self.visit(type.value, type.name)

    def visitSum(self, sum, name):
        self.metadata.types.add(name)

        simple_sum = is_simple(sum)
        if simple_sum:
            self.metadata.simple_sums.add(name)

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 202 Column: 25

                      for dfn in mod.dfns:
            self.visit(dfn)

    def visitType(self, type, depth=0):
        self.visit(type.value, type.name, depth)

    def visitSum(self, sum, name, depth):
        if is_simple(sum):
            self.simple_sum(sum, name, depth)

            

Reported by Pylint.

Redefining built-in 'sum'
Error

Line: 205 Column: 24

                  def visitType(self, type, depth=0):
        self.visit(type.value, type.name, depth)

    def visitSum(self, sum, name, depth):
        if is_simple(sum):
            self.simple_sum(sum, name, depth)
        else:
            self.sum_with_constructors(sum, name, depth)


            

Reported by Pylint.