The following issues were found
Lib/idlelib/idle_test/test_parenmatch.py
17 issues
Line: 31
Column: 9
cls.root.withdraw()
cls.text = Text(cls.root)
cls.editwin = DummyEditwin(cls.text)
cls.editwin.text_frame = Mock()
@classmethod
def tearDownClass(cls):
del cls.text, cls.editwin
cls.root.update_idletasks()
Reported by Pylint.
Line: 7
Column: 1
several text methods not defined on idlelib.idle_test.mock_tk.Text.
"""
from idlelib.parenmatch import ParenMatch
from test.support import requires
requires('gui')
import unittest
from unittest.mock import Mock
from tkinter import Tk, Text
Reported by Pylint.
Line: 10
Column: 1
from test.support import requires
requires('gui')
import unittest
from unittest.mock import Mock
from tkinter import Tk, Text
class DummyEditwin:
Reported by Pylint.
Line: 10
Column: 1
from test.support import requires
requires('gui')
import unittest
from unittest.mock import Mock
from tkinter import Tk, Text
class DummyEditwin:
Reported by Pylint.
Line: 11
Column: 1
requires('gui')
import unittest
from unittest.mock import Mock
from tkinter import Tk, Text
class DummyEditwin:
def __init__(self, text):
Reported by Pylint.
Line: 11
Column: 1
requires('gui')
import unittest
from unittest.mock import Mock
from tkinter import Tk, Text
class DummyEditwin:
def __init__(self, text):
Reported by Pylint.
Line: 12
Column: 1
import unittest
from unittest.mock import Mock
from tkinter import Tk, Text
class DummyEditwin:
def __init__(self, text):
self.text = text
Reported by Pylint.
Line: 12
Column: 1
import unittest
from unittest.mock import Mock
from tkinter import Tk, Text
class DummyEditwin:
def __init__(self, text):
self.text = text
Reported by Pylint.
Line: 15
Column: 1
from tkinter import Tk, Text
class DummyEditwin:
def __init__(self, text):
self.text = text
self.indentwidth = 8
self.tabwidth = 8
self.prompt_last_line = '>>>' # Currently not used by parenmatch.
Reported by Pylint.
Line: 15
Column: 1
from tkinter import Tk, Text
class DummyEditwin:
def __init__(self, text):
self.text = text
self.indentwidth = 8
self.tabwidth = 8
self.prompt_last_line = '>>>' # Currently not used by parenmatch.
Reported by Pylint.
Lib/lib2to3/fixes/fix_imports.py
17 issues
Line: 5
Column: 1
# Authors: Collin Winter, Nick Edds
# Local imports
from .. import fixer_base
from ..fixer_util import Name, attr_chain
MAPPING = {'StringIO': 'io',
'cStringIO': 'io',
'cPickle': 'pickle',
Reported by Pylint.
Line: 6
Column: 1
# Local imports
from .. import fixer_base
from ..fixer_util import Name, attr_chain
MAPPING = {'StringIO': 'io',
'cStringIO': 'io',
'cPickle': 'pickle',
'__builtin__' : 'builtins',
Reported by Pylint.
Line: 65
Column: 1
return "(" + "|".join(map(repr, members)) + ")"
def build_pattern(mapping=MAPPING):
mod_list = ' | '.join(["module_name='%s'" % key for key in mapping])
bare_names = alternates(mapping.keys())
yield """name_import=import_name< 'import' ((%s) |
multiple_imports=dotted_as_names< any* (%s) any* >) >
Reported by Pylint.
Line: 102
Column: 9
def compile_pattern(self):
# We override this, so MAPPING can be pragmatically altered and the
# changes will be reflected in PATTERN.
self.PATTERN = self.build_pattern()
super(FixImports, self).compile_pattern()
# Don't match the node if it's within another match.
def match(self, node):
match = super(FixImports, self).match
Reported by Pylint.
Line: 120
Column: 9
def start_tree(self, tree, filename):
super(FixImports, self).start_tree(tree, filename)
self.replace = {}
def transform(self, node, results):
import_mod = results.get("module_name")
if import_mod:
mod_name = import_mod.value
Reported by Pylint.
Line: 61
Column: 1
}
def alternates(members):
return "(" + "|".join(map(repr, members)) + ")"
def build_pattern(mapping=MAPPING):
mod_list = ' | '.join(["module_name='%s'" % key for key in mapping])
Reported by Pylint.
Line: 65
Column: 1
return "(" + "|".join(map(repr, members)) + ")"
def build_pattern(mapping=MAPPING):
mod_list = ' | '.join(["module_name='%s'" % key for key in mapping])
bare_names = alternates(mapping.keys())
yield """name_import=import_name< 'import' ((%s) |
multiple_imports=dotted_as_names< any* (%s) any* >) >
Reported by Pylint.
Line: 85
Column: 1
yield "power< bare_with_attr=(%s) trailer<'.' any > any* >" % bare_names
class FixImports(fixer_base.BaseFix):
BM_compatible = True
keep_line_order = True
# This is overridden in fix_imports2.
mapping = MAPPING
Reported by Pylint.
Line: 96
Column: 5
# renames into relative imports.
run_order = 6
def build_pattern(self):
return "|".join(build_pattern(self.mapping))
def compile_pattern(self):
# We override this, so MAPPING can be pragmatically altered and the
# changes will be reflected in PATTERN.
Reported by Pylint.
Line: 99
Column: 5
def build_pattern(self):
return "|".join(build_pattern(self.mapping))
def compile_pattern(self):
# We override this, so MAPPING can be pragmatically altered and the
# changes will be reflected in PATTERN.
self.PATTERN = self.build_pattern()
super(FixImports, self).compile_pattern()
Reported by Pylint.
Doc/includes/mp_workers.py
17 issues
Line: 10
Column: 12
# Function run by worker processes
#
def worker(input, output):
for func, args in iter(input.get, 'STOP'):
result = calculate(func, args)
output.put(result)
#
Reported by Pylint.
Line: 54
Column: 9
task_queue.put(task)
# Start worker processes
for i in range(NUMBER_OF_PROCESSES):
Process(target=worker, args=(task_queue, done_queue)).start()
# Get and print results
print('Unordered results:')
for i in range(len(TASKS1)):
Reported by Pylint.
Line: 1
Column: 1
import time
import random
from multiprocessing import Process, Queue, current_process, freeze_support
#
# Function run by worker processes
#
Reported by Pylint.
Line: 10
Column: 1
# Function run by worker processes
#
def worker(input, output):
for func, args in iter(input.get, 'STOP'):
result = calculate(func, args)
output.put(result)
#
Reported by Pylint.
Line: 19
Column: 1
# Function used to calculate result
#
def calculate(func, args):
result = func(*args)
return '%s says that %s%s = %s' % \
(current_process().name, func.__name__, args, result)
#
Reported by Pylint.
Line: 28
Column: 1
# Functions referenced by tasks
#
def mul(a, b):
time.sleep(0.5*random.random())
return a * b
def plus(a, b):
time.sleep(0.5*random.random())
Reported by Pylint.
Line: 28
Column: 1
# Functions referenced by tasks
#
def mul(a, b):
time.sleep(0.5*random.random())
return a * b
def plus(a, b):
time.sleep(0.5*random.random())
Reported by Pylint.
Line: 28
Column: 1
# Functions referenced by tasks
#
def mul(a, b):
time.sleep(0.5*random.random())
return a * b
def plus(a, b):
time.sleep(0.5*random.random())
Reported by Pylint.
Line: 29
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random
#
def mul(a, b):
time.sleep(0.5*random.random())
return a * b
def plus(a, b):
time.sleep(0.5*random.random())
return a + b
Reported by Bandit.
Line: 32
Column: 1
time.sleep(0.5*random.random())
return a * b
def plus(a, b):
time.sleep(0.5*random.random())
return a + b
#
#
Reported by Pylint.
Lib/email/quoprimime.py
17 issues
Line: 84
Column: 19
return chr(octet) != _QUOPRI_BODY_MAP[octet]
def header_length(bytearray):
"""Return a header quoted-printable encoding length.
Note that this does not include any RFC 2047 chrome added by
`header_encode()`.
Reported by Pylint.
Line: 97
Column: 17
return sum(len(_QUOPRI_HEADER_MAP[octet]) for octet in bytearray)
def body_length(bytearray):
"""Return a body quoted-printable encoding length.
:param bytearray: An array of bytes (a.k.a. octets).
:return: The length in bytes of the byte array when it is encoded with
quoted-printable for bodies.
Reported by Pylint.
Line: 123
Column: 11
return chr(int(s[1:3], 16))
def quote(c):
return _QUOPRI_MAP[ord(c)]
def header_encode(header_bytes, charset='iso-8859-1'):
"""Encode a single header line with quoted-printable (like) encoding.
Reported by Pylint.
Line: 252
Column: 13
i = 0
n = len(line)
while i < n:
c = line[i]
if c != '=':
decoded += c
i += 1
# Otherwise, c == "=". Are we at the end of the line? If so, add
# a soft line break.
Reported by Pylint.
Line: 107
Column: 1
return sum(len(_QUOPRI_BODY_MAP[octet]) for octet in bytearray)
def _max_append(L, s, maxlen, extra=''):
if not isinstance(s, str):
s = chr(s)
if not L:
L.append(s.lstrip())
elif len(L[-1]) + len(s) <= maxlen:
Reported by Pylint.
Line: 107
Column: 1
return sum(len(_QUOPRI_BODY_MAP[octet]) for octet in bytearray)
def _max_append(L, s, maxlen, extra=''):
if not isinstance(s, str):
s = chr(s)
if not L:
L.append(s.lstrip())
elif len(L[-1]) + len(s) <= maxlen:
Reported by Pylint.
Line: 118
Column: 1
L.append(s.lstrip())
def unquote(s):
"""Turn a string in the form =AB to the ASCII character with value 0xab"""
return chr(int(s[1:3], 16))
def quote(c):
Reported by Pylint.
Line: 123
Column: 1
return chr(int(s[1:3], 16))
def quote(c):
return _QUOPRI_MAP[ord(c)]
def header_encode(header_bytes, charset='iso-8859-1'):
"""Encode a single header line with quoted-printable (like) encoding.
Reported by Pylint.
Line: 123
Column: 1
return chr(int(s[1:3], 16))
def quote(c):
return _QUOPRI_MAP[ord(c)]
def header_encode(header_bytes, charset='iso-8859-1'):
"""Encode a single header line with quoted-printable (like) encoding.
Reported by Pylint.
Line: 152
Column: 1
for c in b'\r\n':
_QUOPRI_BODY_ENCODE_MAP[c] = chr(c)
def body_encode(body, maxlinelen=76, eol=NL):
"""Encode with quoted-printable, wrapping at maxlinelen characters.
Each line of encoded text will end with eol, which defaults to "\\n". Set
this to "\\r\\n" if you will be using the result of this function directly
in an email.
Reported by Pylint.
Lib/getpass.py
17 issues
Line: 74
Column: 40
new[3] &= ~termios.ECHO # 3 == 'lflags'
tcsetattr_flags = termios.TCSAFLUSH
if hasattr(termios, 'TCSASOFT'):
tcsetattr_flags |= termios.TCSASOFT
try:
termios.tcsetattr(fd, tcsetattr_flags, new)
passwd = _raw_input(prompt, stream, input=input)
finally:
termios.tcsetattr(fd, tcsetattr_flags, old)
Reported by Pylint.
Line: 51
Column: 13
fd = os.open('/dev/tty', os.O_RDWR|os.O_NOCTTY)
tty = io.FileIO(fd, 'w+')
stack.enter_context(tty)
input = io.TextIOWrapper(tty)
stack.enter_context(input)
if not stream:
stream = input
except OSError:
# If that fails, see if stdin can be controlled.
Reported by Pylint.
Line: 129
Column: 40
return _raw_input(prompt, stream)
def _raw_input(prompt="", stream=None, input=None):
# This doesn't save the string in the GNU readline history.
if not stream:
stream = sys.stderr
if not input:
input = sys.stdin
Reported by Pylint.
Line: 176
Column: 5
import termios
# it's possible there is an incompatible termios from the
# McMillan Installer, make sure we have a UNIX-compatible termios
termios.tcgetattr, termios.tcsetattr
except (ImportError, AttributeError):
try:
import msvcrt
except ImportError:
getpass = fallback_getpass
Reported by Pylint.
Line: 26
Column: 1
__all__ = ["getpass","getuser","GetPassWarning"]
class GetPassWarning(UserWarning): pass
def unix_getpass(prompt='Password: ', stream=None):
"""Prompt for a password, with echo turned off.
Reported by Pylint.
Line: 26
Column: 36
__all__ = ["getpass","getuser","GetPassWarning"]
class GetPassWarning(UserWarning): pass
def unix_getpass(prompt='Password: ', stream=None):
"""Prompt for a password, with echo turned off.
Reported by Pylint.
Line: 48
Column: 13
with contextlib.ExitStack() as stack:
try:
# Always try reading and writing directly on the tty first.
fd = os.open('/dev/tty', os.O_RDWR|os.O_NOCTTY)
tty = io.FileIO(fd, 'w+')
stack.enter_context(tty)
input = io.TextIOWrapper(tty)
stack.enter_context(input)
if not stream:
Reported by Pylint.
Line: 59
Column: 17
# If that fails, see if stdin can be controlled.
stack.close()
try:
fd = sys.stdin.fileno()
except (AttributeError, ValueError):
fd = None
passwd = fallback_getpass(prompt, stream)
input = sys.stdin
if not stream:
Reported by Pylint.
Line: 61
Column: 17
try:
fd = sys.stdin.fileno()
except (AttributeError, ValueError):
fd = None
passwd = fallback_getpass(prompt, stream)
input = sys.stdin
if not stream:
stream = sys.stderr
Reported by Pylint.
Line: 102
Column: 9
if sys.stdin is not sys.__stdin__:
return fallback_getpass(prompt, stream)
for c in prompt:
msvcrt.putwch(c)
pw = ""
while 1:
c = msvcrt.getwch()
if c == '\r' or c == '\n':
Reported by Pylint.
Lib/getopt.py
17 issues
Line: 24
Column: 3
#
# Peter Åstrand <astrand@lysator.liu.se> added gnu_getopt().
#
# TODO for gnu_getopt():
#
# - GNU getopt_long_only mechanism
# - allow the caller to specify ordering
# - RETURN_IN_ORDER option
# - GNU extension with '-' as first character of option string
Reported by Pylint.
Line: 56
Column: 1
error = GetoptError # backward compatibility
def getopt(args, shortopts, longopts = []):
"""getopt(args, options[, long_options]) -> opts, args
Parses command line options and parameter list. args is the
argument list to be parsed, without the leading reference to the
running program. Typically, this means "sys.argv[1:]". shortopts
Reported by Pylint.
Line: 99
Column: 1
return opts, args
def gnu_getopt(args, shortopts, longopts = []):
"""getopt(args, options[, long_options]) -> opts, args
This function works like getopt(), except that GNU style scanning
mode is used by default. This means that option and non-option
arguments may be intermixed. The getopt() function stops
Reported by Pylint.
Line: 182
Column: 3
return True, opt
# No exact match, so better be unique.
if len(possibilities) > 1:
# XXX since possibilities contains all valid continuations, might be
# nice to work them into the error msg
raise GetoptError(_('option --%s not a unique prefix') % opt, opt)
assert len(possibilities) == 1
unique_match = possibilities[0]
has_arg = unique_match.endswith('=')
Reported by Pylint.
Line: 41
Column: 5
from gettext import gettext as _
except ImportError:
# Bootstrapping Python: gettext's dependencies not built yet
def _(s): return s
class GetoptError(Exception):
opt = ''
msg = ''
def __init__(self, msg, opt=''):
Reported by Pylint.
Line: 41
Column: 15
from gettext import gettext as _
except ImportError:
# Bootstrapping Python: gettext's dependencies not built yet
def _(s): return s
class GetoptError(Exception):
opt = ''
msg = ''
def __init__(self, msg, opt=''):
Reported by Pylint.
Line: 43
Column: 1
# Bootstrapping Python: gettext's dependencies not built yet
def _(s): return s
class GetoptError(Exception):
opt = ''
msg = ''
def __init__(self, msg, opt=''):
self.msg = msg
self.opt = opt
Reported by Pylint.
Line: 54
Column: 1
def __str__(self):
return self.msg
error = GetoptError # backward compatibility
def getopt(args, shortopts, longopts = []):
"""getopt(args, options[, long_options]) -> opts, args
Parses command line options and parameter list. args is the
Reported by Pylint.
Line: 84
Column: 8
"""
opts = []
if type(longopts) == type(""):
longopts = [longopts]
else:
longopts = list(longopts)
while args and args[0].startswith('-') and args[0] != '-':
if args[0] == '--':
Reported by Pylint.
Line: 140
Column: 13
elif args[0][:1] == '-' and args[0] != '-':
opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:])
else:
if all_options_first:
prog_args += args
break
else:
prog_args.append(args[0])
args = args[1:]
Reported by Pylint.
Mac/Extras.install.py
17 issues
Line: 8
Column: 1
import os
import shutil
verbose = 1
debug = 0
def isclean(name):
if name == 'CVS': return 0
if name == '.cvsignore': return 0
Reported by Pylint.
Line: 9
Column: 1
import shutil
verbose = 1
debug = 0
def isclean(name):
if name == 'CVS': return 0
if name == '.cvsignore': return 0
if name == '.DS_store': return 0
Reported by Pylint.
Line: 11
Column: 1
verbose = 1
debug = 0
def isclean(name):
if name == 'CVS': return 0
if name == '.cvsignore': return 0
if name == '.DS_store': return 0
if name == '.svn': return 0
if name.endswith('~'): return 0
Reported by Pylint.
Line: 11
Column: 1
verbose = 1
debug = 0
def isclean(name):
if name == 'CVS': return 0
if name == '.cvsignore': return 0
if name == '.DS_store': return 0
if name == '.svn': return 0
if name.endswith('~'): return 0
Reported by Pylint.
Line: 12
Column: 23
debug = 0
def isclean(name):
if name == 'CVS': return 0
if name == '.cvsignore': return 0
if name == '.DS_store': return 0
if name == '.svn': return 0
if name.endswith('~'): return 0
if name.endswith('.BAK'): return 0
Reported by Pylint.
Line: 13
Column: 30
def isclean(name):
if name == 'CVS': return 0
if name == '.cvsignore': return 0
if name == '.DS_store': return 0
if name == '.svn': return 0
if name.endswith('~'): return 0
if name.endswith('.BAK'): return 0
if name.endswith('.pyc'): return 0
Reported by Pylint.
Line: 14
Column: 29
def isclean(name):
if name == 'CVS': return 0
if name == '.cvsignore': return 0
if name == '.DS_store': return 0
if name == '.svn': return 0
if name.endswith('~'): return 0
if name.endswith('.BAK'): return 0
if name.endswith('.pyc'): return 0
if name.endswith('.pyo'): return 0
Reported by Pylint.
Line: 15
Column: 24
if name == 'CVS': return 0
if name == '.cvsignore': return 0
if name == '.DS_store': return 0
if name == '.svn': return 0
if name.endswith('~'): return 0
if name.endswith('.BAK'): return 0
if name.endswith('.pyc'): return 0
if name.endswith('.pyo'): return 0
if name.endswith('.orig'): return 0
Reported by Pylint.
Line: 16
Column: 28
if name == '.cvsignore': return 0
if name == '.DS_store': return 0
if name == '.svn': return 0
if name.endswith('~'): return 0
if name.endswith('.BAK'): return 0
if name.endswith('.pyc'): return 0
if name.endswith('.pyo'): return 0
if name.endswith('.orig'): return 0
return 1
Reported by Pylint.
Line: 17
Column: 31
if name == '.DS_store': return 0
if name == '.svn': return 0
if name.endswith('~'): return 0
if name.endswith('.BAK'): return 0
if name.endswith('.pyc'): return 0
if name.endswith('.pyo'): return 0
if name.endswith('.orig'): return 0
return 1
Reported by Pylint.
Lib/test/test_syslog.py
17 issues
Line: 5
Column: 3
syslog = import_helper.import_module("syslog") #skip if not supported
import unittest
# XXX(nnorwitz): This test sucks. I don't know of a platform independent way
# to verify that the messages were really logged.
# The only purpose of this test is to verify the code doesn't crash or leak.
class Test(unittest.TestCase):
Reported by Pylint.
Line: 1
Column: 1
from test.support import import_helper
syslog = import_helper.import_module("syslog") #skip if not supported
import unittest
# XXX(nnorwitz): This test sucks. I don't know of a platform independent way
# to verify that the messages were really logged.
# The only purpose of this test is to verify the code doesn't crash or leak.
class Test(unittest.TestCase):
Reported by Pylint.
Line: 3
Column: 1
from test.support import import_helper
syslog = import_helper.import_module("syslog") #skip if not supported
import unittest
# XXX(nnorwitz): This test sucks. I don't know of a platform independent way
# to verify that the messages were really logged.
# The only purpose of this test is to verify the code doesn't crash or leak.
class Test(unittest.TestCase):
Reported by Pylint.
Line: 9
Column: 1
# to verify that the messages were really logged.
# The only purpose of this test is to verify the code doesn't crash or leak.
class Test(unittest.TestCase):
def test_openlog(self):
syslog.openlog('python')
# Issue #6697.
self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
Reported by Pylint.
Line: 11
Column: 5
class Test(unittest.TestCase):
def test_openlog(self):
syslog.openlog('python')
# Issue #6697.
self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
def test_syslog(self):
Reported by Pylint.
Line: 16
Column: 5
# Issue #6697.
self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
def test_syslog(self):
syslog.openlog('python')
syslog.syslog('test message from python test_syslog')
syslog.syslog(syslog.LOG_ERR, 'test error from python test_syslog')
def test_closelog(self):
Reported by Pylint.
Line: 16
Column: 5
# Issue #6697.
self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
def test_syslog(self):
syslog.openlog('python')
syslog.syslog('test message from python test_syslog')
syslog.syslog(syslog.LOG_ERR, 'test error from python test_syslog')
def test_closelog(self):
Reported by Pylint.
Line: 21
Column: 5
syslog.syslog('test message from python test_syslog')
syslog.syslog(syslog.LOG_ERR, 'test error from python test_syslog')
def test_closelog(self):
syslog.openlog('python')
syslog.closelog()
def test_setlogmask(self):
syslog.setlogmask(syslog.LOG_DEBUG)
Reported by Pylint.
Line: 21
Column: 5
syslog.syslog('test message from python test_syslog')
syslog.syslog(syslog.LOG_ERR, 'test error from python test_syslog')
def test_closelog(self):
syslog.openlog('python')
syslog.closelog()
def test_setlogmask(self):
syslog.setlogmask(syslog.LOG_DEBUG)
Reported by Pylint.
Line: 25
Column: 5
syslog.openlog('python')
syslog.closelog()
def test_setlogmask(self):
syslog.setlogmask(syslog.LOG_DEBUG)
def test_log_mask(self):
syslog.LOG_MASK(syslog.LOG_INFO)
Reported by Pylint.
Lib/test/test_unary.py
17 issues
Line: 10
Column: 26
def test_negative(self):
self.assertTrue(-2 == 0 - 2)
self.assertEqual(-0, 0)
self.assertEqual(--2, 2)
self.assertTrue(-2 == 0 - 2)
self.assertTrue(-2.0 == 0 - 2.0)
self.assertTrue(-2j == 0 - 2j)
def test_positive(self):
Reported by Pylint.
Line: 18
Column: 26
def test_positive(self):
self.assertEqual(+2, 2)
self.assertEqual(+0, 0)
self.assertEqual(++2, 2)
self.assertEqual(+2, 2)
self.assertEqual(+2.0, 2.0)
self.assertEqual(+2j, 2j)
def test_invert(self):
Reported by Pylint.
Line: 26
Column: 26
def test_invert(self):
self.assertTrue(-2 == 0 - 2)
self.assertEqual(-0, 0)
self.assertEqual(--2, 2)
self.assertTrue(-2 == 0 - 2)
def test_no_overflow(self):
nines = "9" * 32
self.assertTrue(eval("+" + nines) == 10**32-1)
Reported by Pylint.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
def test_no_overflow(self):
nines = "9" * 32
self.assertTrue(eval("+" + nines) == 10**32-1)
self.assertTrue(eval("-" + nines) == -(10**32-1))
self.assertTrue(eval("~" + nines) == ~(10**32-1))
def test_negation_of_exponentiation(self):
# Make sure '**' does the right thing; these form a
Reported by Bandit.
Line: 31
Column: 25
def test_no_overflow(self):
nines = "9" * 32
self.assertTrue(eval("+" + nines) == 10**32-1)
self.assertTrue(eval("-" + nines) == -(10**32-1))
self.assertTrue(eval("~" + nines) == ~(10**32-1))
def test_negation_of_exponentiation(self):
# Make sure '**' does the right thing; these form a
Reported by Pylint.
Line: 32
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
def test_no_overflow(self):
nines = "9" * 32
self.assertTrue(eval("+" + nines) == 10**32-1)
self.assertTrue(eval("-" + nines) == -(10**32-1))
self.assertTrue(eval("~" + nines) == ~(10**32-1))
def test_negation_of_exponentiation(self):
# Make sure '**' does the right thing; these form a
# regression test for SourceForge bug #456756.
Reported by Bandit.
Line: 32
Column: 25
def test_no_overflow(self):
nines = "9" * 32
self.assertTrue(eval("+" + nines) == 10**32-1)
self.assertTrue(eval("-" + nines) == -(10**32-1))
self.assertTrue(eval("~" + nines) == ~(10**32-1))
def test_negation_of_exponentiation(self):
# Make sure '**' does the right thing; these form a
# regression test for SourceForge bug #456756.
Reported by Pylint.
Line: 33
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
nines = "9" * 32
self.assertTrue(eval("+" + nines) == 10**32-1)
self.assertTrue(eval("-" + nines) == -(10**32-1))
self.assertTrue(eval("~" + nines) == ~(10**32-1))
def test_negation_of_exponentiation(self):
# Make sure '**' does the right thing; these form a
# regression test for SourceForge bug #456756.
self.assertEqual(-2 ** 3, -8)
Reported by Bandit.
Line: 33
Column: 25
nines = "9" * 32
self.assertTrue(eval("+" + nines) == 10**32-1)
self.assertTrue(eval("-" + nines) == -(10**32-1))
self.assertTrue(eval("~" + nines) == ~(10**32-1))
def test_negation_of_exponentiation(self):
# Make sure '**' does the right thing; these form a
# regression test for SourceForge bug #456756.
self.assertEqual(-2 ** 3, -8)
Reported by Pylint.
Line: 5
Column: 1
import unittest
class UnaryOpTestCase(unittest.TestCase):
def test_negative(self):
self.assertTrue(-2 == 0 - 2)
self.assertEqual(-0, 0)
self.assertEqual(--2, 2)
Reported by Pylint.
Lib/test/test_userstring.py
17 issues
Line: 20
Column: 34
# Overwrite the three testing methods, because UserString
# can't cope with arguments propagated to UserString
# (and we don't test with subclasses)
def checkequal(self, result, object, methodname, *args, **kwargs):
result = self.fixtype(result)
object = self.fixtype(object)
# we don't fix the arguments, because UserString can't cope with it
realresult = getattr(object, methodname)(*args, **kwargs)
self.assertEqual(
Reported by Pylint.
Line: 20
Column: 5
# Overwrite the three testing methods, because UserString
# can't cope with arguments propagated to UserString
# (and we don't test with subclasses)
def checkequal(self, result, object, methodname, *args, **kwargs):
result = self.fixtype(result)
object = self.fixtype(object)
# we don't fix the arguments, because UserString can't cope with it
realresult = getattr(object, methodname)(*args, **kwargs)
self.assertEqual(
Reported by Pylint.
Line: 39
Column: 5
if expected_msg is not None:
self.assertEqual(str(cm.exception), expected_msg)
def checkcall(self, object, methodname, *args):
object = self.fixtype(object)
# we don't fix the arguments, because UserString can't cope with it
getattr(object, methodname)(*args)
def test_rmod(self):
Reported by Pylint.
Line: 39
Column: 25
if expected_msg is not None:
self.assertEqual(str(cm.exception), expected_msg)
def checkcall(self, object, methodname, *args):
object = self.fixtype(object)
# we don't fix the arguments, because UserString can't cope with it
getattr(object, methodname)(*args)
def test_rmod(self):
Reported by Pylint.
Line: 49
Column: 13
pass
class ustr3(ustr2):
def __rmod__(self, other):
return super().__rmod__(other)
fmt2 = ustr2('value is %s')
str3 = ustr3('TEST')
self.assertEqual(fmt2 % str3, 'value is TEST')
Reported by Pylint.
Line: 1
Column: 1
# UserString is a wrapper around the native builtin string type.
# UserString instances should behave similar to builtin string objects.
import unittest
from test import string_tests
from collections import UserString
class UserStringTest(
Reported by Pylint.
Line: 9
Column: 1
from collections import UserString
class UserStringTest(
string_tests.CommonTest,
string_tests.MixinStrUnicodeUserStringTest,
unittest.TestCase
):
Reported by Pylint.
Line: 33
Column: 40
def checkraises(self, exc, obj, methodname, *args, expected_msg=None):
obj = self.fixtype(obj)
# we don't fix the arguments, because UserString can't cope with it
with self.assertRaises(exc) as cm:
getattr(obj, methodname)(*args)
self.assertNotEqual(str(cm.exception), '')
if expected_msg is not None:
self.assertEqual(str(cm.exception), expected_msg)
Reported by Pylint.
Line: 44
Column: 5
# we don't fix the arguments, because UserString can't cope with it
getattr(object, methodname)(*args)
def test_rmod(self):
class ustr2(UserString):
pass
class ustr3(ustr2):
def __rmod__(self, other):
Reported by Pylint.
Line: 45
Column: 9
getattr(object, methodname)(*args)
def test_rmod(self):
class ustr2(UserString):
pass
class ustr3(ustr2):
def __rmod__(self, other):
return super().__rmod__(other)
Reported by Pylint.