The following issues were found
Lib/test/test_importlib/threaded_import_hangers.py
6 issues
Line: 22
Column: 34
# to do its own imports it will block waiting for this module's import
# to complete.
class Worker(threading.Thread):
def __init__(self, function, args):
threading.Thread.__init__(self)
self.function = function
self.args = args
def run(self):
Reported by Pylint.
Line: 1
Column: 1
# This is a helper module for test_threaded_import. The test imports this
# module, and this module tries to run various Python library functions in
# their own thread, as a side effect of being imported. If the spawned
# thread doesn't complete in TIMEOUT seconds, an "appeared to hang" message
# is appended to the module-global `errors` list. That list remains empty
# if (and only if) all functions tested complete.
TIMEOUT = 10
Reported by Pylint.
Line: 10
Column: 1
TIMEOUT = 10
import threading
import tempfile
import os.path
errors = []
Reported by Pylint.
Line: 12
Column: 1
import threading
import tempfile
import os.path
errors = []
# This class merely runs a function in its own thread T. The thread importing
Reported by Pylint.
Line: 13
Column: 1
import threading
import tempfile
import os.path
errors = []
# This class merely runs a function in its own thread T. The thread importing
# this module holds the import lock, so if the function called by T tries
Reported by Pylint.
Line: 21
Column: 1
# this module holds the import lock, so if the function called by T tries
# to do its own imports it will block waiting for this module's import
# to complete.
class Worker(threading.Thread):
def __init__(self, function, args):
threading.Thread.__init__(self)
self.function = function
self.args = args
Reported by Pylint.
Lib/lib2to3/tests/test_all_fixers.py
6 issues
Line: 13
Column: 1
import test.support
# Local imports
from . import support
@test.support.requires_resource('cpu')
class Test_all(support.TestCase):
Reported by Pylint.
Line: 17
Column: 1
@test.support.requires_resource('cpu')
class Test_all(support.TestCase):
def setUp(self):
self.refactor = support.get_refactorer()
def test_all_project_files(self):
Reported by Pylint.
Line: 17
Column: 1
@test.support.requires_resource('cpu')
class Test_all(support.TestCase):
def setUp(self):
self.refactor = support.get_refactorer()
def test_all_project_files(self):
Reported by Pylint.
Line: 19
Column: 5
@test.support.requires_resource('cpu')
class Test_all(support.TestCase):
def setUp(self):
self.refactor = support.get_refactorer()
def test_all_project_files(self):
for filepath in support.all_project_files():
self.refactor.refactor_file(filepath)
Reported by Pylint.
Line: 19
Column: 5
@test.support.requires_resource('cpu')
class Test_all(support.TestCase):
def setUp(self):
self.refactor = support.get_refactorer()
def test_all_project_files(self):
for filepath in support.all_project_files():
self.refactor.refactor_file(filepath)
Reported by Pylint.
Line: 22
Column: 5
def setUp(self):
self.refactor = support.get_refactorer()
def test_all_project_files(self):
for filepath in support.all_project_files():
self.refactor.refactor_file(filepath)
if __name__ == '__main__':
unittest.main()
Reported by Pylint.
Lib/test/test_crashers.py
6 issues
Line: 1
Column: 1
# Tests that the crashers in the Lib/test/crashers directory actually
# do crash the interpreter as expected
#
# If a crasher is fixed, it should be moved elsewhere in the test suite to
# ensure it continues to work correctly.
import unittest
import glob
import os.path
Reported by Pylint.
Line: 18
Column: 1
infinite_loops = ["infinite_loop_re.py", "nasty_eq_vs_dict.py"]
class CrasherTest(unittest.TestCase):
@unittest.skip("these tests are too fragile")
@test.support.cpython_only
def test_crashers_crash(self):
for fname in glob.glob(CRASHER_FILES):
Reported by Pylint.
Line: 22
Column: 5
@unittest.skip("these tests are too fragile")
@test.support.cpython_only
def test_crashers_crash(self):
for fname in glob.glob(CRASHER_FILES):
if os.path.basename(fname) in infinite_loops:
continue
# Some "crashers" only trigger an exception rather than a
# segfault. Consider that an acceptable outcome.
Reported by Pylint.
Line: 22
Column: 5
@unittest.skip("these tests are too fragile")
@test.support.cpython_only
def test_crashers_crash(self):
for fname in glob.glob(CRASHER_FILES):
if os.path.basename(fname) in infinite_loops:
continue
# Some "crashers" only trigger an exception rather than a
# segfault. Consider that an acceptable outcome.
Reported by Pylint.
Line: 33
Column: 1
assert_python_failure(fname)
def tearDownModule():
test.support.reap_children()
if __name__ == "__main__":
unittest.main()
Reported by Pylint.
Line: 33
Column: 1
assert_python_failure(fname)
def tearDownModule():
test.support.reap_children()
if __name__ == "__main__":
unittest.main()
Reported by Pylint.
Lib/test/subprocessdata/sigchild_ignore.py
6 issues
Line: 1
Column: 1
import signal, subprocess, sys, time
# On Linux this causes os.waitpid to fail with OSError as the OS has already
# reaped our child process. The wait() passing the OSError on to the caller
# and causing us to exit with an error is what we are testing against.
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0
Reported by Pylint.
Line: 1
Column: 1
import signal, subprocess, sys, time
# On Linux this causes os.waitpid to fail with OSError as the OS has already
# reaped our child process. The wait() passing the OSError on to the caller
# and causing us to exit with an error is what we are testing against.
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0
Reported by Pylint.
Line: 1
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import signal, subprocess, sys, time
# On Linux this causes os.waitpid to fail with OSError as the OS has already
# reaped our child process. The wait() passing the OSError on to the caller
# and causing us to exit with an error is what we are testing against.
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0
Reported by Bandit.
Line: 6
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
# reaped our child process. The wait() passing the OSError on to the caller
# and causing us to exit with an error is what we are testing against.
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0
while p.poll() is None:
# Waiting for the process to finish.
Reported by Bandit.
Line: 8
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0
while p.poll() is None:
# Waiting for the process to finish.
time.sleep(0.01) # Avoid being a CPU busy loop.
num_polls += 1
Reported by Bandit.
Line: 9
Column: 1
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0
while p.poll() is None:
# Waiting for the process to finish.
time.sleep(0.01) # Avoid being a CPU busy loop.
num_polls += 1
if num_polls > 3000:
Reported by Pylint.
Lib/test/badsyntax_future8.py
6 issues
Line: 3
Column: 1
"""This is a test"""
from __future__ import *
def f(x):
def g(y):
return x + y
return g
Reported by Pylint.
Line: 5
Column: 1
from __future__ import *
def f(x):
def g(y):
return x + y
return g
print(f(2)(4))
Reported by Pylint.
Line: 5
Column: 1
from __future__ import *
def f(x):
def g(y):
return x + y
return g
print(f(2)(4))
Reported by Pylint.
Line: 5
Column: 1
from __future__ import *
def f(x):
def g(y):
return x + y
return g
print(f(2)(4))
Reported by Pylint.
Line: 6
Column: 5
from __future__ import *
def f(x):
def g(y):
return x + y
return g
print(f(2)(4))
Reported by Pylint.
Line: 6
Column: 5
from __future__ import *
def f(x):
def g(y):
return x + y
return g
print(f(2)(4))
Reported by Pylint.
Lib/test/test_codecmaps_jp.py
6 issues
Line: 1
Column: 1
#
# test_codecmaps_jp.py
# Codec mapping tests for Japanese encodings
#
from test import multibytecodec_support
import unittest
class TestCP932Map(multibytecodec_support.TestBase_Mapping,
Reported by Pylint.
Line: 9
Column: 1
from test import multibytecodec_support
import unittest
class TestCP932Map(multibytecodec_support.TestBase_Mapping,
unittest.TestCase):
encoding = 'cp932'
mapfileurl = 'http://www.pythontest.net/unicode/CP932.TXT'
supmaps = [
(b'\x80', '\u0080'),
Reported by Pylint.
Line: 24
Column: 1
supmaps.append((bytes([i]), chr(i+0xfec0)))
class TestEUCJPCOMPATMap(multibytecodec_support.TestBase_Mapping,
unittest.TestCase):
encoding = 'euc_jp'
mapfilename = 'EUC-JP.TXT'
mapfileurl = 'http://www.pythontest.net/unicode/EUC-JP.TXT'
Reported by Pylint.
Line: 31
Column: 1
mapfileurl = 'http://www.pythontest.net/unicode/EUC-JP.TXT'
class TestSJISCOMPATMap(multibytecodec_support.TestBase_Mapping,
unittest.TestCase):
encoding = 'shift_jis'
mapfilename = 'SHIFTJIS.TXT'
mapfileurl = 'http://www.pythontest.net/unicode/SHIFTJIS.TXT'
pass_enctest = [
Reported by Pylint.
Line: 45
Column: 1
(b'\x81_', '\\'),
]
class TestEUCJISX0213Map(multibytecodec_support.TestBase_Mapping,
unittest.TestCase):
encoding = 'euc_jisx0213'
mapfilename = 'EUC-JISX0213.TXT'
mapfileurl = 'http://www.pythontest.net/unicode/EUC-JISX0213.TXT'
Reported by Pylint.
Line: 52
Column: 1
mapfileurl = 'http://www.pythontest.net/unicode/EUC-JISX0213.TXT'
class TestSJISX0213Map(multibytecodec_support.TestBase_Mapping,
unittest.TestCase):
encoding = 'shift_jisx0213'
mapfilename = 'SHIFT_JISX0213.TXT'
mapfileurl = 'http://www.pythontest.net/unicode/SHIFT_JISX0213.TXT'
Reported by Pylint.
Lib/test/dataclass_textanno.py
6 issues
Line: 1
Column: 1
from __future__ import annotations
import dataclasses
class Foo:
pass
Reported by Pylint.
Line: 6
Column: 1
import dataclasses
class Foo:
pass
@dataclasses.dataclass
class Bar:
Reported by Pylint.
Line: 6
Column: 1
import dataclasses
class Foo:
pass
@dataclasses.dataclass
class Bar:
Reported by Pylint.
Line: 11
Column: 1
@dataclasses.dataclass
class Bar:
foo: Foo
Reported by Pylint.
Line: 12
Column: 5
@dataclasses.dataclass
class Bar:
foo: Foo
Reported by Pylint.
Line: 12
Column: 5
@dataclasses.dataclass
class Bar:
foo: Foo
Reported by Pylint.
Doc/includes/sqlite3/adapter_point_2.py
6 issues
Line: 1
Column: 1
import sqlite3
class Point:
def __init__(self, x, y):
self.x, self.y = x, y
def adapt_point(point):
return "%f;%f" % (point.x, point.y)
Reported by Pylint.
Line: 3
Column: 1
import sqlite3
class Point:
def __init__(self, x, y):
self.x, self.y = x, y
def adapt_point(point):
return "%f;%f" % (point.x, point.y)
Reported by Pylint.
Line: 3
Column: 1
import sqlite3
class Point:
def __init__(self, x, y):
self.x, self.y = x, y
def adapt_point(point):
return "%f;%f" % (point.x, point.y)
Reported by Pylint.
Line: 5
Column: 17
class Point:
def __init__(self, x, y):
self.x, self.y = x, y
def adapt_point(point):
return "%f;%f" % (point.x, point.y)
sqlite3.register_adapter(Point, adapt_point)
Reported by Pylint.
Line: 5
Column: 9
class Point:
def __init__(self, x, y):
self.x, self.y = x, y
def adapt_point(point):
return "%f;%f" % (point.x, point.y)
sqlite3.register_adapter(Point, adapt_point)
Reported by Pylint.
Line: 7
Column: 1
def __init__(self, x, y):
self.x, self.y = x, y
def adapt_point(point):
return "%f;%f" % (point.x, point.y)
sqlite3.register_adapter(Point, adapt_point)
con = sqlite3.connect(":memory:")
Reported by Pylint.
Lib/distutils/tests/test_text_file.py
6 issues
Line: 50
Column: 24
# "collapse" joined lines
result6 = ["line 3 continues on next line"]
def test_input(count, description, file, expected_result):
result = file.readlines()
self.assertEqual(result, expected_result)
tmpdir = self.mkdtemp()
filename = os.path.join(tmpdir, "test.txt")
Reported by Pylint.
Line: 50
Column: 31
# "collapse" joined lines
result6 = ["line 3 continues on next line"]
def test_input(count, description, file, expected_result):
result = file.readlines()
self.assertEqual(result, expected_result)
tmpdir = self.mkdtemp()
filename = os.path.join(tmpdir, "test.txt")
Reported by Pylint.
Line: 15
Column: 1
continues on next line
"""
class TextFileTestCase(support.TempdirManager, unittest.TestCase):
def test_class(self):
# old tests moved from text_file.__main__
# so they are really called by the buildbots
Reported by Pylint.
Line: 17
Column: 5
class TextFileTestCase(support.TempdirManager, unittest.TestCase):
def test_class(self):
# old tests moved from text_file.__main__
# so they are really called by the buildbots
# result 1: no fancy options
result1 = ['# test file\n', '\n', 'line 3 \\\n',
Reported by Pylint.
Line: 17
Column: 5
class TextFileTestCase(support.TempdirManager, unittest.TestCase):
def test_class(self):
# old tests moved from text_file.__main__
# so they are really called by the buildbots
# result 1: no fancy options
result1 = ['# test file\n', '\n', 'line 3 \\\n',
Reported by Pylint.
Line: 103
Column: 1
finally:
in_file.close()
def test_suite():
return unittest.makeSuite(TextFileTestCase)
if __name__ == "__main__":
run_unittest(test_suite())
Reported by Pylint.
Lib/idlelib/idle_test/test_debugger.py
6 issues
Line: 4
Column: 1
"Test debugger, coverage 19%"
from idlelib import debugger
import unittest
from test.support import requires
requires('gui')
from tkinter import Tk
Reported by Pylint.
Line: 5
Column: 1
from idlelib import debugger
import unittest
from test.support import requires
requires('gui')
from tkinter import Tk
class NameSpaceTest(unittest.TestCase):
Reported by Pylint.
Line: 7
Column: 1
import unittest
from test.support import requires
requires('gui')
from tkinter import Tk
class NameSpaceTest(unittest.TestCase):
@classmethod
Reported by Pylint.
Line: 7
Column: 1
import unittest
from test.support import requires
requires('gui')
from tkinter import Tk
class NameSpaceTest(unittest.TestCase):
@classmethod
Reported by Pylint.
Line: 10
Column: 1
from tkinter import Tk
class NameSpaceTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.root = Tk()
cls.root.withdraw()
Reported by Pylint.
Line: 22
Column: 5
cls.root.destroy()
del cls.root
def test_init(self):
debugger.NamespaceViewer(self.root, 'Test')
# Other classes are Idb, Debugger, and StackViewer.
Reported by Pylint.