The following issues were found
Lib/test/test_getopt.py
17 issues
Line: 178
Column: 19
run_doctest(m, verbose)
def test_issue4629(self):
longopts, shortopts = getopt.getopt(['--help='], '', ['help='])
self.assertEqual(longopts, [('--help', '')])
longopts, shortopts = getopt.getopt(['--help=x'], '', ['help='])
self.assertEqual(longopts, [('--help', 'x')])
self.assertRaises(getopt.GetoptError, getopt.getopt, ['--help='], '', ['help'])
Reported by Pylint.
Line: 1
Column: 1
# test_getopt.py
# David Goodger <dgoodger@bigfoot.com> 2000-08-19
from test.support import verbose, run_doctest
from test.support.os_helper import EnvironmentVarGuard
import unittest
import getopt
Reported by Pylint.
Line: 12
Column: 1
sentinel = object()
class GetoptTests(unittest.TestCase):
def setUp(self):
self.env = EnvironmentVarGuard()
if "POSIXLY_CORRECT" in self.env:
del self.env["POSIXLY_CORRECT"]
Reported by Pylint.
Line: 22
Column: 5
self.env.__exit__()
del self.env
def assertError(self, *args, **kwargs):
self.assertRaises(getopt.GetoptError, *args, **kwargs)
def test_short_has_arg(self):
self.assertTrue(getopt.short_has_arg('a', 'a:'))
self.assertFalse(getopt.short_has_arg('a', 'a'))
Reported by Pylint.
Line: 22
Column: 5
self.env.__exit__()
del self.env
def assertError(self, *args, **kwargs):
self.assertRaises(getopt.GetoptError, *args, **kwargs)
def test_short_has_arg(self):
self.assertTrue(getopt.short_has_arg('a', 'a:'))
self.assertFalse(getopt.short_has_arg('a', 'a'))
Reported by Pylint.
Line: 25
Column: 5
def assertError(self, *args, **kwargs):
self.assertRaises(getopt.GetoptError, *args, **kwargs)
def test_short_has_arg(self):
self.assertTrue(getopt.short_has_arg('a', 'a:'))
self.assertFalse(getopt.short_has_arg('a', 'a'))
self.assertError(getopt.short_has_arg, 'a', 'b')
def test_long_has_args(self):
Reported by Pylint.
Line: 30
Column: 5
self.assertFalse(getopt.short_has_arg('a', 'a'))
self.assertError(getopt.short_has_arg, 'a', 'b')
def test_long_has_args(self):
has_arg, option = getopt.long_has_args('abc', ['abc='])
self.assertTrue(has_arg)
self.assertEqual(option, 'abc')
has_arg, option = getopt.long_has_args('abc', ['abc'])
Reported by Pylint.
Line: 47
Column: 5
self.assertError(getopt.long_has_args, 'abc', [])
self.assertError(getopt.long_has_args, 'abc', ['abcd','abcde'])
def test_do_shorts(self):
opts, args = getopt.do_shorts([], 'a', 'a', [])
self.assertEqual(opts, [('-a', '')])
self.assertEqual(args, [])
opts, args = getopt.do_shorts([], 'a1', 'a:', [])
Reported by Pylint.
Line: 71
Column: 5
self.assertError(getopt.do_shorts, [], 'a1', 'a', [])
self.assertError(getopt.do_shorts, [], 'a', 'a:', [])
def test_do_longs(self):
opts, args = getopt.do_longs([], 'abc', ['abc'], [])
self.assertEqual(opts, [('--abc', '')])
self.assertEqual(args, [])
opts, args = getopt.do_longs([], 'abc=1', ['abc='], [])
Reported by Pylint.
Line: 98
Column: 5
self.assertError(getopt.do_longs, [], 'abc=1', ['abc'], [])
self.assertError(getopt.do_longs, [], 'abc', ['abc='], [])
def test_getopt(self):
# note: the empty string between '-a' and '--beta' is significant:
# it simulates an empty string option argument ('-a ""') on the
# command line.
cmdline = ['-a', '1', '-b', '--alpha=2', '--beta', '-a', '3', '-a',
'', '--beta', 'arg1', 'arg2']
Reported by Pylint.
Lib/sqlite3/test/dump.py
16 issues
Line: 44
Column: 9
"CREATE VIEW v1 as select * from t1 left join t2 " \
"using (id);"
]
[self.cu.execute(s) for s in expected_sqls]
i = self.cx.iterdump()
actual_sqls = [s for s in i]
expected_sqls = ['BEGIN TRANSACTION;'] + expected_sqls + \
['COMMIT;']
[self.assertEqual(expected_sqls[i], actual_sqls[i])
Reported by Pylint.
Line: 49
Column: 9
actual_sqls = [s for s in i]
expected_sqls = ['BEGIN TRANSACTION;'] + expected_sqls + \
['COMMIT;']
[self.assertEqual(expected_sqls[i], actual_sqls[i])
for i in range(len(expected_sqls))]
def test_unorderable_row(self):
# iterdump() should be able to cope with unorderable row types (issue #15545)
class UnorderableRow:
Reported by Pylint.
Line: 55
Column: 32
def test_unorderable_row(self):
# iterdump() should be able to cope with unorderable row types (issue #15545)
class UnorderableRow:
def __init__(self, cursor, row):
self.row = row
def __getitem__(self, index):
return self.row[index]
self.cx.row_factory = UnorderableRow
CREATE_ALPHA = """CREATE TABLE "alpha" ("one");"""
Reported by Pylint.
Line: 1
Column: 1
# Author: Paul Kippes <kippesp@gmail.com>
import unittest
import sqlite3 as sqlite
class DumpTests(unittest.TestCase):
def setUp(self):
self.cx = sqlite.connect(":memory:")
self.cu = self.cx.cursor()
Reported by Pylint.
Line: 6
Column: 1
import unittest
import sqlite3 as sqlite
class DumpTests(unittest.TestCase):
def setUp(self):
self.cx = sqlite.connect(":memory:")
self.cu = self.cx.cursor()
def tearDown(self):
Reported by Pylint.
Line: 8
Column: 9
class DumpTests(unittest.TestCase):
def setUp(self):
self.cx = sqlite.connect(":memory:")
self.cu = self.cx.cursor()
def tearDown(self):
self.cx.close()
Reported by Pylint.
Line: 9
Column: 9
class DumpTests(unittest.TestCase):
def setUp(self):
self.cx = sqlite.connect(":memory:")
self.cu = self.cx.cursor()
def tearDown(self):
self.cx.close()
def test_table_dump(self):
Reported by Pylint.
Line: 14
Column: 5
def tearDown(self):
self.cx.close()
def test_table_dump(self):
expected_sqls = [
"""CREATE TABLE "index"("index" blob);"""
,
"""INSERT INTO "index" VALUES(X'01');"""
,
Reported by Pylint.
Line: 46
Column: 1
]
[self.cu.execute(s) for s in expected_sqls]
i = self.cx.iterdump()
actual_sqls = [s for s in i]
expected_sqls = ['BEGIN TRANSACTION;'] + expected_sqls + \
['COMMIT;']
[self.assertEqual(expected_sqls[i], actual_sqls[i])
for i in range(len(expected_sqls))]
Reported by Pylint.
Line: 52
Column: 5
[self.assertEqual(expected_sqls[i], actual_sqls[i])
for i in range(len(expected_sqls))]
def test_unorderable_row(self):
# iterdump() should be able to cope with unorderable row types (issue #15545)
class UnorderableRow:
def __init__(self, cursor, row):
self.row = row
def __getitem__(self, index):
Reported by Pylint.
Lib/multiprocessing/popen_fork.py
16 issues
Line: 4
Column: 1
import os
import signal
from . import util
__all__ = ['Popen']
#
# Start child process using fork
Reported by Pylint.
Line: 33
Column: 35
# e.errno == errno.ECHILD == 10
return None
if pid == self.pid:
self.returncode = os.waitstatus_to_exitcode(sts)
return self.returncode
def wait(self, timeout=None):
if self.returncode is None:
if timeout is not None:
Reported by Pylint.
Line: 71
Column: 24
try:
os.close(parent_r)
os.close(parent_w)
code = process_obj._bootstrap(parent_sentinel=child_r)
finally:
os._exit(code)
else:
os.close(child_w)
os.close(child_r)
Reported by Pylint.
Line: 73
Column: 17
os.close(parent_w)
code = process_obj._bootstrap(parent_sentinel=child_r)
finally:
os._exit(code)
else:
os.close(child_w)
os.close(child_r)
self.finalizer = util.Finalize(self, util.close_fds,
(parent_r, parent_w,))
Reported by Pylint.
Line: 1
Column: 1
import os
import signal
from . import util
__all__ = ['Popen']
#
# Start child process using fork
Reported by Pylint.
Line: 12
Column: 1
# Start child process using fork
#
class Popen(object):
method = 'fork'
def __init__(self, process_obj):
util._flush_std_streams()
self.returncode = None
Reported by Pylint.
Line: 12
Column: 1
# Start child process using fork
#
class Popen(object):
method = 'fork'
def __init__(self, process_obj):
util._flush_std_streams()
self.returncode = None
Reported by Pylint.
Line: 21
Column: 5
self.finalizer = None
self._launch(process_obj)
def duplicate_for_child(self, fd):
return fd
def poll(self, flag=os.WNOHANG):
if self.returncode is None:
try:
Reported by Pylint.
Line: 21
Column: 5
self.finalizer = None
self._launch(process_obj)
def duplicate_for_child(self, fd):
return fd
def poll(self, flag=os.WNOHANG):
if self.returncode is None:
try:
Reported by Pylint.
Line: 21
Column: 5
self.finalizer = None
self._launch(process_obj)
def duplicate_for_child(self, fd):
return fd
def poll(self, flag=os.WNOHANG):
if self.returncode is None:
try:
Reported by Pylint.
Lib/test/test_importlib/test_reader.py
16 issues
Line: 1
Column: 1
import os.path
import sys
import pathlib
import unittest
from importlib import import_module
from importlib.readers import MultiplexedPath, NamespaceReader
Reported by Pylint.
Line: 10
Column: 1
from importlib.readers import MultiplexedPath, NamespaceReader
class MultiplexedPathTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
path = pathlib.Path(__file__).parent / 'namespacedata01'
cls.folder = str(path)
Reported by Pylint.
Line: 16
Column: 5
path = pathlib.Path(__file__).parent / 'namespacedata01'
cls.folder = str(path)
def test_init_no_paths(self):
with self.assertRaises(FileNotFoundError):
MultiplexedPath()
def test_init_file(self):
with self.assertRaises(NotADirectoryError):
Reported by Pylint.
Line: 20
Column: 5
with self.assertRaises(FileNotFoundError):
MultiplexedPath()
def test_init_file(self):
with self.assertRaises(NotADirectoryError):
MultiplexedPath(os.path.join(self.folder, 'binary.file'))
def test_iterdir(self):
contents = {path.name for path in MultiplexedPath(self.folder).iterdir()}
Reported by Pylint.
Line: 24
Column: 5
with self.assertRaises(NotADirectoryError):
MultiplexedPath(os.path.join(self.folder, 'binary.file'))
def test_iterdir(self):
contents = {path.name for path in MultiplexedPath(self.folder).iterdir()}
try:
contents.remove('__pycache__')
except (KeyError, ValueError):
pass
Reported by Pylint.
Line: 32
Column: 5
pass
self.assertEqual(contents, {'binary.file', 'utf-16.file', 'utf-8.file'})
def test_iterdir_duplicate(self):
data01 = os.path.abspath(os.path.join(__file__, '..', 'data01'))
contents = {
path.name for path in MultiplexedPath(self.folder, data01).iterdir()
}
for remove in ('__pycache__', '__init__.pyc'):
Reported by Pylint.
Line: 47
Column: 5
{'__init__.py', 'binary.file', 'subdirectory', 'utf-16.file', 'utf-8.file'},
)
def test_is_dir(self):
self.assertEqual(MultiplexedPath(self.folder).is_dir(), True)
def test_is_file(self):
self.assertEqual(MultiplexedPath(self.folder).is_file(), False)
Reported by Pylint.
Line: 50
Column: 5
def test_is_dir(self):
self.assertEqual(MultiplexedPath(self.folder).is_dir(), True)
def test_is_file(self):
self.assertEqual(MultiplexedPath(self.folder).is_file(), False)
def test_open_file(self):
path = MultiplexedPath(self.folder)
with self.assertRaises(FileNotFoundError):
Reported by Pylint.
Line: 53
Column: 5
def test_is_file(self):
self.assertEqual(MultiplexedPath(self.folder).is_file(), False)
def test_open_file(self):
path = MultiplexedPath(self.folder)
with self.assertRaises(FileNotFoundError):
path.read_bytes()
with self.assertRaises(FileNotFoundError):
path.read_text()
Reported by Pylint.
Line: 62
Column: 5
with self.assertRaises(FileNotFoundError):
path.open()
def test_join_path(self):
prefix = os.path.abspath(os.path.join(__file__, '..'))
data01 = os.path.join(prefix, 'data01')
path = MultiplexedPath(self.folder, data01)
self.assertEqual(
str(path.joinpath('binary.file'))[len(prefix) + 1 :],
Reported by Pylint.
Lib/test/test_int_literal.py
16 issues
Line: 8
Column: 1
import unittest
class TestHexOctBin(unittest.TestCase):
def test_hex_baseline(self):
# A few upper/lowercase tests
self.assertEqual(0x0, 0X0)
self.assertEqual(0x1, 0X1)
Reported by Pylint.
Line: 10
Column: 5
class TestHexOctBin(unittest.TestCase):
def test_hex_baseline(self):
# A few upper/lowercase tests
self.assertEqual(0x0, 0X0)
self.assertEqual(0x1, 0X1)
self.assertEqual(0x123456789abcdef, 0X123456789abcdef)
# Baseline tests
Reported by Pylint.
Line: 31
Column: 5
self.assertEqual(-0x7fffffff, -2147483647)
self.assertEqual(-0x7fffffffffffffff, -9223372036854775807)
def test_hex_unsigned(self):
# Positive constants
self.assertEqual(0x80000000, 2147483648)
self.assertEqual(0xffffffff, 4294967295)
# Ditto with a minus sign and parentheses
self.assertEqual(-(0x80000000), -2147483648)
Reported by Pylint.
Line: 54
Column: 5
self.assertEqual(-0x8000000000000000, -9223372036854775808)
self.assertEqual(-0xffffffffffffffff, -18446744073709551615)
def test_oct_baseline(self):
# A few upper/lowercase tests
self.assertEqual(0o0, 0O0)
self.assertEqual(0o1, 0O1)
self.assertEqual(0o1234567, 0O1234567)
# Baseline tests
Reported by Pylint.
Line: 75
Column: 5
self.assertEqual(-0o17777777777, -2147483647)
self.assertEqual(-0o777777777777777777777, -9223372036854775807)
def test_oct_unsigned(self):
# Positive constants
self.assertEqual(0o20000000000, 2147483648)
self.assertEqual(0o37777777777, 4294967295)
# Ditto with a minus sign and parentheses
self.assertEqual(-(0o20000000000), -2147483648)
Reported by Pylint.
Line: 98
Column: 5
self.assertEqual(-0o1000000000000000000000, -9223372036854775808)
self.assertEqual(-0o1777777777777777777777, -18446744073709551615)
def test_bin_baseline(self):
# A few upper/lowercase tests
self.assertEqual(0b0, 0B0)
self.assertEqual(0b1, 0B1)
self.assertEqual(0b10101010101, 0B10101010101)
# Baseline tests
Reported by Pylint.
Line: 107
Column: 1
self.assertEqual(0b0, 0)
self.assertEqual(0b10000, 16)
self.assertEqual(0b1111111111111111111111111111111, 2147483647)
self.assertEqual(0b111111111111111111111111111111111111111111111111111111111111111, 9223372036854775807)
# Ditto with a minus sign and parentheses
self.assertEqual(-(0b0), 0)
self.assertEqual(-(0b10000), -16)
self.assertEqual(-(0b1111111111111111111111111111111), -2147483647)
self.assertEqual(-(0b111111111111111111111111111111111111111111111111111111111111111), -9223372036854775807)
Reported by Pylint.
Line: 112
Column: 1
self.assertEqual(-(0b0), 0)
self.assertEqual(-(0b10000), -16)
self.assertEqual(-(0b1111111111111111111111111111111), -2147483647)
self.assertEqual(-(0b111111111111111111111111111111111111111111111111111111111111111), -9223372036854775807)
# Ditto with a minus sign and NO parentheses
self.assertEqual(-0b0, 0)
self.assertEqual(-0b10000, -16)
self.assertEqual(-0b1111111111111111111111111111111, -2147483647)
self.assertEqual(-0b111111111111111111111111111111111111111111111111111111111111111, -9223372036854775807)
Reported by Pylint.
Line: 117
Column: 1
self.assertEqual(-0b0, 0)
self.assertEqual(-0b10000, -16)
self.assertEqual(-0b1111111111111111111111111111111, -2147483647)
self.assertEqual(-0b111111111111111111111111111111111111111111111111111111111111111, -9223372036854775807)
def test_bin_unsigned(self):
# Positive constants
self.assertEqual(0b10000000000000000000000000000000, 2147483648)
self.assertEqual(0b11111111111111111111111111111111, 4294967295)
Reported by Pylint.
Line: 119
Column: 5
self.assertEqual(-0b1111111111111111111111111111111, -2147483647)
self.assertEqual(-0b111111111111111111111111111111111111111111111111111111111111111, -9223372036854775807)
def test_bin_unsigned(self):
# Positive constants
self.assertEqual(0b10000000000000000000000000000000, 2147483648)
self.assertEqual(0b11111111111111111111111111111111, 4294967295)
# Ditto with a minus sign and parentheses
self.assertEqual(-(0b10000000000000000000000000000000), -2147483648)
Reported by Pylint.
Lib/test/test_importlib/source/test_path_hook.py
16 issues
Line: 1
Column: 1
from .. import util
machinery = util.import_importlib('importlib.machinery')
import unittest
class PathHookTest:
Reported by Pylint.
Line: 13
Column: 53
"""Test the path hook for source."""
def path_hook(self):
return self.machinery.FileFinder.path_hook((self.machinery.SourceFileLoader,
self.machinery.SOURCE_SUFFIXES))
def test_success(self):
with util.create_modules('dummy') as mapping:
self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
Reported by Pylint.
Line: 13
Column: 16
"""Test the path hook for source."""
def path_hook(self):
return self.machinery.FileFinder.path_hook((self.machinery.SourceFileLoader,
self.machinery.SOURCE_SUFFIXES))
def test_success(self):
with util.create_modules('dummy') as mapping:
self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
Reported by Pylint.
Line: 14
Column: 13
def path_hook(self):
return self.machinery.FileFinder.path_hook((self.machinery.SourceFileLoader,
self.machinery.SOURCE_SUFFIXES))
def test_success(self):
with util.create_modules('dummy') as mapping:
self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
'find_spec'))
Reported by Pylint.
Line: 18
Column: 13
def test_success(self):
with util.create_modules('dummy') as mapping:
self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
'find_spec'))
def test_success_legacy(self):
with util.create_modules('dummy') as mapping:
self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
Reported by Pylint.
Line: 23
Column: 13
def test_success_legacy(self):
with util.create_modules('dummy') as mapping:
self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
'find_module'))
def test_empty_string(self):
# The empty string represents the cwd.
self.assertTrue(hasattr(self.path_hook()(''), 'find_spec'))
Reported by Pylint.
Line: 28
Column: 9
def test_empty_string(self):
# The empty string represents the cwd.
self.assertTrue(hasattr(self.path_hook()(''), 'find_spec'))
def test_empty_string_legacy(self):
# The empty string represents the cwd.
self.assertTrue(hasattr(self.path_hook()(''), 'find_module'))
Reported by Pylint.
Line: 32
Column: 9
def test_empty_string_legacy(self):
# The empty string represents the cwd.
self.assertTrue(hasattr(self.path_hook()(''), 'find_module'))
(Frozen_PathHookTest,
Source_PathHooktest
) = util.test_both(PathHookTest, machinery=machinery)
Reported by Pylint.
Line: 1
Column: 1
from .. import util
machinery = util.import_importlib('importlib.machinery')
import unittest
class PathHookTest:
Reported by Pylint.
Line: 5
Column: 1
machinery = util.import_importlib('importlib.machinery')
import unittest
class PathHookTest:
"""Test the path hook for source."""
Reported by Pylint.
Lib/test/test___future__.py
16 issues
Line: 15
Column: 52
given_feature_names = features[:]
for name in dir(__future__):
obj = getattr(__future__, name, None)
if obj is not None and isinstance(obj, __future__._Feature):
self.assertTrue(
name in given_feature_names,
"%r should have been in all_feature_names" % name
)
given_feature_names.remove(name)
Reported by Pylint.
Line: 34
Column: 17
a = self.assertTrue
e = self.assertEqual
def check(t, name):
a(isinstance(t, tuple), "%s isn't tuple" % name)
e(len(t), 5, "%s isn't 5-tuple" % name)
(major, minor, micro, level, serial) = t
a(isinstance(major, int), "%s major isn't int" % name)
a(isinstance(minor, int), "%s minor isn't int" % name)
a(isinstance(micro, int), "%s micro isn't int" % name)
Reported by Pylint.
Line: 35
Column: 17
e = self.assertEqual
def check(t, name):
a(isinstance(t, tuple), "%s isn't tuple" % name)
e(len(t), 5, "%s isn't 5-tuple" % name)
(major, minor, micro, level, serial) = t
a(isinstance(major, int), "%s major isn't int" % name)
a(isinstance(minor, int), "%s minor isn't int" % name)
a(isinstance(micro, int), "%s micro isn't int" % name)
a(isinstance(level, str),
Reported by Pylint.
Line: 37
Column: 17
a(isinstance(t, tuple), "%s isn't tuple" % name)
e(len(t), 5, "%s isn't 5-tuple" % name)
(major, minor, micro, level, serial) = t
a(isinstance(major, int), "%s major isn't int" % name)
a(isinstance(minor, int), "%s minor isn't int" % name)
a(isinstance(micro, int), "%s micro isn't int" % name)
a(isinstance(level, str),
"%s level isn't string" % name)
a(level in GOOD_SERIALS,
Reported by Pylint.
Line: 38
Column: 17
e(len(t), 5, "%s isn't 5-tuple" % name)
(major, minor, micro, level, serial) = t
a(isinstance(major, int), "%s major isn't int" % name)
a(isinstance(minor, int), "%s minor isn't int" % name)
a(isinstance(micro, int), "%s micro isn't int" % name)
a(isinstance(level, str),
"%s level isn't string" % name)
a(level in GOOD_SERIALS,
"%s level string has unknown value" % name)
Reported by Pylint.
Line: 39
Column: 17
(major, minor, micro, level, serial) = t
a(isinstance(major, int), "%s major isn't int" % name)
a(isinstance(minor, int), "%s minor isn't int" % name)
a(isinstance(micro, int), "%s micro isn't int" % name)
a(isinstance(level, str),
"%s level isn't string" % name)
a(level in GOOD_SERIALS,
"%s level string has unknown value" % name)
a(isinstance(serial, int), "%s serial isn't int" % name)
Reported by Pylint.
Line: 40
Column: 17
a(isinstance(major, int), "%s major isn't int" % name)
a(isinstance(minor, int), "%s minor isn't int" % name)
a(isinstance(micro, int), "%s micro isn't int" % name)
a(isinstance(level, str),
"%s level isn't string" % name)
a(level in GOOD_SERIALS,
"%s level string has unknown value" % name)
a(isinstance(serial, int), "%s serial isn't int" % name)
Reported by Pylint.
Line: 42
Column: 17
a(isinstance(micro, int), "%s micro isn't int" % name)
a(isinstance(level, str),
"%s level isn't string" % name)
a(level in GOOD_SERIALS,
"%s level string has unknown value" % name)
a(isinstance(serial, int), "%s serial isn't int" % name)
check(optional, "optional")
if mandatory is not None:
Reported by Pylint.
Line: 44
Column: 17
"%s level isn't string" % name)
a(level in GOOD_SERIALS,
"%s level string has unknown value" % name)
a(isinstance(serial, int), "%s serial isn't int" % name)
check(optional, "optional")
if mandatory is not None:
check(mandatory, "mandatory")
a(optional < mandatory,
Reported by Pylint.
Line: 1
Column: 1
import unittest
import __future__
GOOD_SERIALS = ("alpha", "beta", "candidate", "final")
features = __future__.all_feature_names
class FutureTest(unittest.TestCase):
Reported by Pylint.
Lib/turtledemo/tree.py
16 issues
Line: 18
Column: 1
the current pen is cloned. So in the end
there are 1024 turtles.
"""
from turtle import Turtle, mainloop
from time import perf_counter as clock
def tree(plist, l, a, f):
""" plist is list of pens
l is length of branch
Reported by Pylint.
Line: 36
Column: 13
q.right(a)
lst.append(p)
lst.append(q)
for x in tree(lst, l*f, a, f):
yield None
def maketree():
p = Turtle()
p.setundobuffer(None)
Reported by Pylint.
Line: 50
Column: 9
p.forward(-210)
p.pendown()
t = tree([p], 200, 65, 0.6375)
for x in t:
pass
def main():
a=clock()
maketree()
Reported by Pylint.
Line: 21
Column: 1
from turtle import Turtle, mainloop
from time import perf_counter as clock
def tree(plist, l, a, f):
""" plist is list of pens
l is length of branch
a is half of the angle between 2 branches
f is factor by which branch is shortened
from level to level."""
Reported by Pylint.
Line: 21
Column: 1
from turtle import Turtle, mainloop
from time import perf_counter as clock
def tree(plist, l, a, f):
""" plist is list of pens
l is length of branch
a is half of the angle between 2 branches
f is factor by which branch is shortened
from level to level."""
Reported by Pylint.
Line: 21
Column: 1
from turtle import Turtle, mainloop
from time import perf_counter as clock
def tree(plist, l, a, f):
""" plist is list of pens
l is length of branch
a is half of the angle between 2 branches
f is factor by which branch is shortened
from level to level."""
Reported by Pylint.
Line: 29
Column: 13
from level to level."""
if l > 3:
lst = []
for p in plist:
p.forward(l)
q = p.clone()
p.left(a)
q.right(a)
lst.append(p)
Reported by Pylint.
Line: 31
Column: 13
lst = []
for p in plist:
p.forward(l)
q = p.clone()
p.left(a)
q.right(a)
lst.append(p)
lst.append(q)
for x in tree(lst, l*f, a, f):
Reported by Pylint.
Line: 36
Column: 13
q.right(a)
lst.append(p)
lst.append(q)
for x in tree(lst, l*f, a, f):
yield None
def maketree():
p = Turtle()
p.setundobuffer(None)
Reported by Pylint.
Line: 39
Column: 1
for x in tree(lst, l*f, a, f):
yield None
def maketree():
p = Turtle()
p.setundobuffer(None)
p.hideturtle()
p.speed(0)
p.getscreen().tracer(30,0)
Reported by Pylint.
Lib/unittest/test/testmock/testsentinel.py
16 issues
Line: 32
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b301-pickle
for proto in range(pickle.HIGHEST_PROTOCOL+1):
with self.subTest(protocol=proto):
pickled = pickle.dumps(sentinel.whatever, proto)
unpickled = pickle.loads(pickled)
self.assertIs(unpickled, sentinel.whatever)
def testCopy(self):
self.assertIs(copy.copy(sentinel.whatever), sentinel.whatever)
self.assertIs(copy.deepcopy(sentinel.whatever), sentinel.whatever)
Reported by Bandit.
Line: 1
Column: 1
import unittest
import copy
import pickle
from unittest.mock import sentinel, DEFAULT
class SentinelTest(unittest.TestCase):
def testSentinels(self):
Reported by Pylint.
Line: 3
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b403-import-pickle
import unittest
import copy
import pickle
from unittest.mock import sentinel, DEFAULT
class SentinelTest(unittest.TestCase):
def testSentinels(self):
Reported by Bandit.
Line: 7
Column: 1
from unittest.mock import sentinel, DEFAULT
class SentinelTest(unittest.TestCase):
def testSentinels(self):
self.assertEqual(sentinel.whatever, sentinel.whatever,
'sentinel not stored')
self.assertNotEqual(sentinel.whatever, sentinel.whateverelse,
Reported by Pylint.
Line: 9
Column: 5
class SentinelTest(unittest.TestCase):
def testSentinels(self):
self.assertEqual(sentinel.whatever, sentinel.whatever,
'sentinel not stored')
self.assertNotEqual(sentinel.whatever, sentinel.whateverelse,
'sentinel should be unique')
Reported by Pylint.
Line: 9
Column: 5
class SentinelTest(unittest.TestCase):
def testSentinels(self):
self.assertEqual(sentinel.whatever, sentinel.whatever,
'sentinel not stored')
self.assertNotEqual(sentinel.whatever, sentinel.whateverelse,
'sentinel should be unique')
Reported by Pylint.
Line: 16
Column: 5
'sentinel should be unique')
def testSentinelName(self):
self.assertEqual(str(sentinel.whatever), 'sentinel.whatever',
'sentinel name incorrect')
def testDEFAULT(self):
Reported by Pylint.
Line: 16
Column: 5
'sentinel should be unique')
def testSentinelName(self):
self.assertEqual(str(sentinel.whatever), 'sentinel.whatever',
'sentinel name incorrect')
def testDEFAULT(self):
Reported by Pylint.
Line: 21
Column: 5
'sentinel name incorrect')
def testDEFAULT(self):
self.assertIs(DEFAULT, sentinel.DEFAULT)
def testBases(self):
# If this doesn't raise an AttributeError then help(mock) is broken
self.assertRaises(AttributeError, lambda: sentinel.__bases__)
Reported by Pylint.
Line: 21
Column: 5
'sentinel name incorrect')
def testDEFAULT(self):
self.assertIs(DEFAULT, sentinel.DEFAULT)
def testBases(self):
# If this doesn't raise an AttributeError then help(mock) is broken
self.assertRaises(AttributeError, lambda: sentinel.__bases__)
Reported by Pylint.
Tools/freeze/winmakemakefile.py
16 issues
Line: 45
Column: 25
raise ValueError("The subsystem %s is not known" % subsystem) from None
def makemakefile(outfp, vars, files, target):
save = sys.stdout
try:
sys.stdout = outfp
realwork(vars, files, target)
finally:
Reported by Pylint.
Line: 53
Column: 14
finally:
sys.stdout = save
def realwork(vars, moddefns, target):
version_suffix = "%r%r" % sys.version_info[:2]
print("# Makefile for Microsoft Visual C++ generated by freeze.py script")
print()
print('target = %s' % target)
print('pythonhome = %s' % vars['prefix'])
Reported by Pylint.
Line: 107
Column: 19
print("# Module", moddefn.name)
for file in moddefn.sourceFiles:
base = os.path.basename(file)
base, ext = os.path.splitext(base)
objects.append(base + ".obj")
print(r'$(temp_dir)\%s.obj: "%s"' % (base, file))
print("\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE", end=' ')
print('"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\')
print("\t\t$(cflags) $(cdebug) $(cinclude) \\")
Reported by Pylint.
Line: 1
Column: 1
import sys, os
# Template used then the program is a GUI program
WINMAINTEMPLATE = """
#include <windows.h>
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
Reported by Pylint.
Line: 1
Column: 1
import sys, os
# Template used then the program is a GUI program
WINMAINTEMPLATE = """
#include <windows.h>
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
Reported by Pylint.
Line: 38
Column: 1
'com_dll' : ("", 0, 1),
}
def get_custom_entry_point(subsystem):
try:
return subsystem_details[subsystem][:2]
except KeyError:
raise ValueError("The subsystem %s is not known" % subsystem) from None
Reported by Pylint.
Line: 45
Column: 1
raise ValueError("The subsystem %s is not known" % subsystem) from None
def makemakefile(outfp, vars, files, target):
save = sys.stdout
try:
sys.stdout = outfp
realwork(vars, files, target)
finally:
Reported by Pylint.
Line: 53
Column: 1
finally:
sys.stdout = save
def realwork(vars, moddefns, target):
version_suffix = "%r%r" % sys.version_info[:2]
print("# Makefile for Microsoft Visual C++ generated by freeze.py script")
print()
print('target = %s' % target)
print('pythonhome = %s' % vars['prefix'])
Reported by Pylint.
Line: 53
Column: 1
finally:
sys.stdout = save
def realwork(vars, moddefns, target):
version_suffix = "%r%r" % sys.version_info[:2]
print("# Makefile for Microsoft Visual C++ generated by freeze.py script")
print()
print('target = %s' % target)
print('pythonhome = %s' % vars['prefix'])
Reported by Pylint.
Line: 53
Column: 1
finally:
sys.stdout = save
def realwork(vars, moddefns, target):
version_suffix = "%r%r" % sys.version_info[:2]
print("# Makefile for Microsoft Visual C++ generated by freeze.py script")
print()
print('target = %s' % target)
print('pythonhome = %s' % vars['prefix'])
Reported by Pylint.