The following issues were found
Lib/ast.py
339 issues
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
Line: 15
Column: 5
def fail():
raise SyntaxError
yield 1
class BadCmp:
def __eq__(self, other):
raise RuntimeError
Reported by Pylint.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
Line: 307
Column: 19
def testUnboundLocal(self):
def errorInOuter():
print(y)
def inner():
return y
y = 1
def errorInInner():
Reported by Pylint.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.