The following issues were found
Lib/logging/handlers.py
146 issues
Line: 73
Column: 16
in doRollover().
"""
try:
if self.shouldRollover(record):
self.doRollover()
logging.FileHandler.emit(self, record)
except Exception:
self.handleError(record)
Reported by Pylint.
Line: 74
Column: 17
"""
try:
if self.shouldRollover(record):
self.doRollover()
logging.FileHandler.emit(self, record)
except Exception:
self.handleError(record)
def rotation_filename(self, default_name):
Reported by Pylint.
Line: 95
Column: 22
if not callable(self.namer):
result = default_name
else:
result = self.namer(default_name)
return result
def rotate(self, source, dest):
"""
When rotating, rotate the current log.
Reported by Pylint.
Line: 117
Column: 13
if os.path.exists(source):
os.rename(source, dest)
else:
self.rotator(source, dest)
class RotatingFileHandler(BaseRotatingHandler):
"""
Handler for logging to a set of files, which switches from one file
to the next when the current file reaches a certain size.
Reported by Pylint.
Line: 76
Column: 16
if self.shouldRollover(record):
self.doRollover()
logging.FileHandler.emit(self, record)
except Exception:
self.handleError(record)
def rotation_filename(self, default_name):
"""
Modify the filename of a log file when rotating.
Reported by Pylint.
Line: 341
Column: 30
result = newRolloverAt
return result
def shouldRollover(self, record):
"""
Determine if rollover should occur.
record is not used, as we are just comparing times, but it is needed so
the method signatures are the same
Reported by Pylint.
Line: 577
Column: 21
except OSError:
#Creation failed, so set the retry time and return.
if self.retryTime is None:
self.retryPeriod = self.retryStart
else:
self.retryPeriod = self.retryPeriod * self.retryFactor
if self.retryPeriod > self.retryMax:
self.retryPeriod = self.retryMax
self.retryTime = now + self.retryPeriod
Reported by Pylint.
Line: 579
Column: 21
if self.retryTime is None:
self.retryPeriod = self.retryStart
else:
self.retryPeriod = self.retryPeriod * self.retryFactor
if self.retryPeriod > self.retryMax:
self.retryPeriod = self.retryMax
self.retryTime = now + self.retryPeriod
def send(self, s):
Reported by Pylint.
Line: 581
Column: 25
else:
self.retryPeriod = self.retryPeriod * self.retryFactor
if self.retryPeriod > self.retryMax:
self.retryPeriod = self.retryMax
self.retryTime = now + self.retryPeriod
def send(self, s):
"""
Send a pickled string to the socket.
Reported by Pylint.
Line: 651
Column: 16
try:
s = self.makePickle(record)
self.send(s)
except Exception:
self.handleError(record)
def close(self):
"""
Closes the socket.
Reported by Pylint.
Lib/pickletools.py
145 issues
Line: 212
Column: 16
from struct import unpack as _unpack
def read_uint1(f):
r"""
>>> import io
>>> read_uint1(io.BytesIO(b'\xff'))
255
"""
Reported by Pylint.
Line: 231
Column: 16
doc="One-byte unsigned integer.")
def read_uint2(f):
r"""
>>> import io
>>> read_uint2(io.BytesIO(b'\xff\x00'))
255
>>> read_uint2(io.BytesIO(b'\xff\xff'))
Reported by Pylint.
Line: 252
Column: 15
doc="Two-byte unsigned integer, little-endian.")
def read_int4(f):
r"""
>>> import io
>>> read_int4(io.BytesIO(b'\xff\x00\x00\x00'))
255
>>> read_int4(io.BytesIO(b'\x00\x00\x00\x80')) == -(2**31)
Reported by Pylint.
Line: 273
Column: 16
doc="Four-byte signed integer, little-endian, 2's complement.")
def read_uint4(f):
r"""
>>> import io
>>> read_uint4(io.BytesIO(b'\xff\x00\x00\x00'))
255
>>> read_uint4(io.BytesIO(b'\x00\x00\x00\x80')) == 2**31
Reported by Pylint.
Line: 294
Column: 16
doc="Four-byte unsigned integer, little-endian.")
def read_uint8(f):
r"""
>>> import io
>>> read_uint8(io.BytesIO(b'\xff\x00\x00\x00\x00\x00\x00\x00'))
255
>>> read_uint8(io.BytesIO(b'\xff' * 8)) == 2**64-1
Reported by Pylint.
Line: 315
Column: 19
doc="Eight-byte unsigned integer, little-endian.")
def read_stringnl(f, decode=True, stripquotes=True):
r"""
>>> import io
>>> read_stringnl(io.BytesIO(b"'abcd'\nefg\n"))
'abcd'
Reported by Pylint.
Line: 372
Column: 28
bracketing quotes.
""")
def read_stringnl_noescape(f):
return read_stringnl(f, stripquotes=False)
stringnl_noescape = ArgumentDescriptor(
name='stringnl_noescape',
n=UP_TO_NEWLINE,
Reported by Pylint.
Line: 386
Column: 33
printable ASCII characters.
""")
def read_stringnl_noescape_pair(f):
r"""
>>> import io
>>> read_stringnl_noescape_pair(io.BytesIO(b"Queue\nEmpty\njunk"))
'Queue Empty'
"""
Reported by Pylint.
Line: 409
Column: 18
""")
def read_string1(f):
r"""
>>> import io
>>> read_string1(io.BytesIO(b"\x00"))
''
>>> read_string1(io.BytesIO(b"\x03abcdef"))
Reported by Pylint.
Line: 438
Column: 18
""")
def read_string4(f):
r"""
>>> import io
>>> read_string4(io.BytesIO(b"\x00\x00\x00\x00abc"))
''
>>> read_string4(io.BytesIO(b"\x03\x00\x00\x00abcdef"))
Reported by Pylint.
Lib/idlelib/tooltip.py
145 issues
Line: 7
Column: 1
* an abstract base-class for different kinds of tooltips
* a simple text-only Tooltip class
"""
from tkinter import *
class TooltipBase:
"""abstract base class for tooltips"""
Reported by Pylint.
Line: 7
Column: 1
* an abstract base-class for different kinds of tooltips
* a simple text-only Tooltip class
"""
from tkinter import *
class TooltipBase:
"""abstract base class for tooltips"""
Reported by Pylint.
Line: 7
Column: 1
* an abstract base-class for different kinds of tooltips
* a simple text-only Tooltip class
"""
from tkinter import *
class TooltipBase:
"""abstract base class for tooltips"""
Reported by Pylint.
Line: 7
Column: 1
* an abstract base-class for different kinds of tooltips
* a simple text-only Tooltip class
"""
from tkinter import *
class TooltipBase:
"""abstract base class for tooltips"""
Reported by Pylint.
Line: 7
Column: 1
* an abstract base-class for different kinds of tooltips
* a simple text-only Tooltip class
"""
from tkinter import *
class TooltipBase:
"""abstract base class for tooltips"""
Reported by Pylint.
Line: 7
Column: 1
* an abstract base-class for different kinds of tooltips
* a simple text-only Tooltip class
"""
from tkinter import *
class TooltipBase:
"""abstract base class for tooltips"""
Reported by Pylint.
Line: 7
Column: 1
* an abstract base-class for different kinds of tooltips
* a simple text-only Tooltip class
"""
from tkinter import *
class TooltipBase:
"""abstract base class for tooltips"""
Reported by Pylint.
Line: 7
Column: 1
* an abstract base-class for different kinds of tooltips
* a simple text-only Tooltip class
"""
from tkinter import *
class TooltipBase:
"""abstract base class for tooltips"""
Reported by Pylint.
Line: 7
Column: 1
* an abstract base-class for different kinds of tooltips
* a simple text-only Tooltip class
"""
from tkinter import *
class TooltipBase:
"""abstract base class for tooltips"""
Reported by Pylint.
Line: 7
Column: 1
* an abstract base-class for different kinds of tooltips
* a simple text-only Tooltip class
"""
from tkinter import *
class TooltipBase:
"""abstract base class for tooltips"""
Reported by Pylint.
Lib/test/libregrtest/save_env.py
145 issues
Line: 77
Column: 13
try:
return self.get_module(name)
except KeyError:
raise SkipTestEnvironment
def get_urllib_requests__url_tempfiles(self):
urllib_request = self.try_get_module('urllib.request')
return list(urllib_request._url_tempfiles)
def restore_urllib_requests__url_tempfiles(self, tempfiles):
Reported by Pylint.
Line: 81
Column: 21
def get_urllib_requests__url_tempfiles(self):
urllib_request = self.try_get_module('urllib.request')
return list(urllib_request._url_tempfiles)
def restore_urllib_requests__url_tempfiles(self, tempfiles):
for filename in tempfiles:
os_helper.unlink(filename)
def get_urllib_requests__opener(self):
Reported by Pylint.
Line: 88
Column: 16
def get_urllib_requests__opener(self):
urllib_request = self.try_get_module('urllib.request')
return urllib_request._opener
def restore_urllib_requests__opener(self, opener):
urllib_request = self.get_module('urllib.request')
urllib_request._opener = opener
def get_asyncio_events__event_loop_policy(self):
Reported by Pylint.
Line: 91
Column: 9
return urllib_request._opener
def restore_urllib_requests__opener(self, opener):
urllib_request = self.get_module('urllib.request')
urllib_request._opener = opener
def get_asyncio_events__event_loop_policy(self):
self.try_get_module('asyncio')
return support.maybe_get_event_loop_policy()
def restore_asyncio_events__event_loop_policy(self, policy):
Reported by Pylint.
Line: 165
Column: 3
def get_asyncore_socket_map(self):
asyncore = sys.modules.get('asyncore')
# XXX Making a copy keeps objects alive until __exit__ gets called.
return asyncore and asyncore.socket_map.copy() or {}
def restore_asyncore_socket_map(self, saved_map):
asyncore = sys.modules.get('asyncore')
if asyncore is not None:
asyncore.close_all(ignore_all=True)
Reported by Pylint.
Line: 178
Column: 16
# we could call get_archives_formats() but that only returns the
# registry keys; we want to check the values too (the functions that
# are registered)
return shutil._ARCHIVE_FORMATS, shutil._ARCHIVE_FORMATS.copy()
def restore_shutil_archive_formats(self, saved):
shutil = self.get_module('shutil')
shutil._ARCHIVE_FORMATS = saved[0]
shutil._ARCHIVE_FORMATS.clear()
shutil._ARCHIVE_FORMATS.update(saved[1])
Reported by Pylint.
Line: 178
Column: 41
# we could call get_archives_formats() but that only returns the
# registry keys; we want to check the values too (the functions that
# are registered)
return shutil._ARCHIVE_FORMATS, shutil._ARCHIVE_FORMATS.copy()
def restore_shutil_archive_formats(self, saved):
shutil = self.get_module('shutil')
shutil._ARCHIVE_FORMATS = saved[0]
shutil._ARCHIVE_FORMATS.clear()
shutil._ARCHIVE_FORMATS.update(saved[1])
Reported by Pylint.
Line: 181
Column: 9
return shutil._ARCHIVE_FORMATS, shutil._ARCHIVE_FORMATS.copy()
def restore_shutil_archive_formats(self, saved):
shutil = self.get_module('shutil')
shutil._ARCHIVE_FORMATS = saved[0]
shutil._ARCHIVE_FORMATS.clear()
shutil._ARCHIVE_FORMATS.update(saved[1])
def get_shutil_unpack_formats(self):
shutil = self.try_get_module('shutil')
Reported by Pylint.
Line: 182
Column: 9
def restore_shutil_archive_formats(self, saved):
shutil = self.get_module('shutil')
shutil._ARCHIVE_FORMATS = saved[0]
shutil._ARCHIVE_FORMATS.clear()
shutil._ARCHIVE_FORMATS.update(saved[1])
def get_shutil_unpack_formats(self):
shutil = self.try_get_module('shutil')
return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy()
Reported by Pylint.
Line: 183
Column: 9
shutil = self.get_module('shutil')
shutil._ARCHIVE_FORMATS = saved[0]
shutil._ARCHIVE_FORMATS.clear()
shutil._ARCHIVE_FORMATS.update(saved[1])
def get_shutil_unpack_formats(self):
shutil = self.try_get_module('shutil')
return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy()
def restore_shutil_unpack_formats(self, saved):
Reported by Pylint.
Lib/doctest.py
144 issues
Line: 103
Column: 1
import pdb
import re
import sys
import traceback
import unittest
from io import StringIO, IncrementalNewlineDecoder
from collections import namedtuple
TestResults = namedtuple('TestResults', 'failed attempted')
Reported by Pylint.
Line: 1469
Column: 17
out = save_stdout.write
else:
# Use backslashreplace error handling on write
def out(s):
s = str(s.encode(encoding, 'backslashreplace'), encoding)
save_stdout.write(s)
sys.stdout = self._fakeout
# Patch pdb.set_trace to restore sys.stdout during interactive
Reported by Pylint.
Line: 210
Column: 28
elif isinstance(module, str):
return __import__(module, globals(), locals(), ["*"])
elif module is None:
return sys.modules[sys._getframe(depth).f_globals['__name__']]
else:
raise TypeError("Expected a module, string, or None")
def _newline_convert(data):
# The IO module provides a handy decoder for universal newline conversion
Reported by Pylint.
Line: 371
Column: 21
def set_trace(self, frame=None):
self.__debugger_used = True
if frame is None:
frame = sys._getframe().f_back
pdb.Pdb.set_trace(self, frame)
def set_continue(self):
# Calling set_continue unconditionally would break unit test
# coverage reporting, as Bdb.set_continue calls sys.settrace(None).
Reported by Pylint.
Line: 948
Column: 36
tests.sort()
return tests
def _from_module(self, module, object):
"""
Return true if the given object is defined in the given
module.
"""
if module is None:
Reported by Pylint.
Line: 1236
Column: 33
# Reporting methods
#/////////////////////////////////////////////////////////////////
def report_start(self, out, test, example):
"""
Report that the test runner is about to process the given
example. (Only displays a message if verbose=True)
"""
if self._verbose:
Reported by Pylint.
Line: 1249
Column: 41
out('Trying:\n' + _indent(example.source) +
'Expecting nothing\n')
def report_success(self, out, test, example, got):
"""
Report that the given example ran successfully. (Only
displays a message if verbose=True)
"""
if self._verbose:
Reported by Pylint.
Line: 1249
Column: 35
out('Trying:\n' + _indent(example.source) +
'Expecting nothing\n')
def report_success(self, out, test, example, got):
"""
Report that the given example ran successfully. (Only
displays a message if verbose=True)
"""
if self._verbose:
Reported by Pylint.
Line: 1249
Column: 50
out('Trying:\n' + _indent(example.source) +
'Expecting nothing\n')
def report_success(self, out, test, example, got):
"""
Report that the given example ran successfully. (Only
displays a message if verbose=True)
"""
if self._verbose:
Reported by Pylint.
Line: 1348
Column: 17
# keyboard interrupts.)
try:
# Don't blink! This is where the user's code gets run.
exec(compile(example.source, filename, "single",
compileflags, True), test.globs)
self.debugger.set_continue() # ==== Example Finished ====
exception = None
except KeyboardInterrupt:
raise
Reported by Pylint.
Lib/test/test_file.py
143 issues
Line: 19
Column: 18
# file tests for which a test file is automatically set up
def setUp(self):
self.f = self.open(TESTFN, 'wb')
def tearDown(self):
if self.f:
self.f.close()
os_helper.unlink(TESTFN)
Reported by Pylint.
Line: 30
Column: 9
# verify weak references
p = proxy(self.f)
p.write(b'teststring')
self.assertEqual(self.f.tell(), p.tell())
self.f.close()
self.f = None
self.assertRaises(ReferenceError, getattr, p, 'tell')
def testAttributes(self):
Reported by Pylint.
Line: 33
Column: 9
self.assertEqual(self.f.tell(), p.tell())
self.f.close()
self.f = None
self.assertRaises(ReferenceError, getattr, p, 'tell')
def testAttributes(self):
# verify expected attributes exist
f = self.f
f.name # merely shouldn't blow up
Reported by Pylint.
Line: 47
Column: 18
self.f.write(b'12')
self.f.close()
a = array('b', b'x'*10)
self.f = self.open(TESTFN, 'rb')
n = self.f.readinto(a)
self.assertEqual(b'12', a.tobytes()[:n])
def testReadinto_text(self):
# verify readinto refuses text files
Reported by Pylint.
Line: 49
Column: 9
a = array('b', b'x'*10)
self.f = self.open(TESTFN, 'rb')
n = self.f.readinto(a)
self.assertEqual(b'12', a.tobytes()[:n])
def testReadinto_text(self):
# verify readinto refuses text files
a = array('b', b'x'*10)
self.f.close()
Reported by Pylint.
Line: 55
Column: 18
# verify readinto refuses text files
a = array('b', b'x'*10)
self.f.close()
self.f = self.open(TESTFN, encoding="utf-8")
if hasattr(self.f, "readinto"):
self.assertRaises(TypeError, self.f.readinto, a)
def testWritelinesUserList(self):
# verify writelines with instance sequence
Reported by Pylint.
Line: 57
Column: 13
self.f.close()
self.f = self.open(TESTFN, encoding="utf-8")
if hasattr(self.f, "readinto"):
self.assertRaises(TypeError, self.f.readinto, a)
def testWritelinesUserList(self):
# verify writelines with instance sequence
l = UserList([b'1', b'2'])
self.f.writelines(l)
Reported by Pylint.
Line: 64
Column: 18
l = UserList([b'1', b'2'])
self.f.writelines(l)
self.f.close()
self.f = self.open(TESTFN, 'rb')
buf = self.f.read()
self.assertEqual(buf, b'12')
def testWritelinesIntegers(self):
# verify writelines with integers
Reported by Pylint.
Line: 66
Column: 9
self.f.close()
self.f = self.open(TESTFN, 'rb')
buf = self.f.read()
self.assertEqual(buf, b'12')
def testWritelinesIntegers(self):
# verify writelines with integers
self.assertRaises(TypeError, self.f.writelines, [1, 2, 3])
Reported by Pylint.
Line: 70
Column: 9
def testWritelinesIntegers(self):
# verify writelines with integers
self.assertRaises(TypeError, self.f.writelines, [1, 2, 3])
def testWritelinesIntegersUserList(self):
# verify writelines with integers in UserList
l = UserList([1,2,3])
self.assertRaises(TypeError, self.f.writelines, l)
Reported by Pylint.
Lib/test/test_tokenize.py
143 issues
Line: 10
Column: 1
from io import BytesIO, StringIO
import unittest
from unittest import TestCase, mock
from test.test_grammar import (VALID_UNDERSCORE_LITERALS,
INVALID_UNDERSCORE_LITERALS)
import os
import token
Reported by Pylint.
Line: 10
Column: 1
from io import BytesIO, StringIO
import unittest
from unittest import TestCase, mock
from test.test_grammar import (VALID_UNDERSCORE_LITERALS,
INVALID_UNDERSCORE_LITERALS)
import os
import token
Reported by Pylint.
Line: 25
Column: 34
num_lines = len(source_string.splitlines())
missing_trailing_nl = source_string[-1] not in '\r\n'
for type, token, start, end, line in token_generator:
if type == ENDMARKER:
break
# Ignore the new line on the last line if the input lacks one
if missing_trailing_nl and type == NEWLINE and end[0] == num_lines:
continue
Reported by Pylint.
Line: 25
Column: 15
num_lines = len(source_string.splitlines())
missing_trailing_nl = source_string[-1] not in '\r\n'
for type, token, start, end, line in token_generator:
if type == ENDMARKER:
break
# Ignore the new line on the last line if the input lacks one
if missing_trailing_nl and type == NEWLINE and end[0] == num_lines:
continue
Reported by Pylint.
Line: 25
Column: 9
num_lines = len(source_string.splitlines())
missing_trailing_nl = source_string[-1] not in '\r\n'
for type, token, start, end, line in token_generator:
if type == ENDMARKER:
break
# Ignore the new line on the last line if the input lacks one
if missing_trailing_nl and type == NEWLINE and end[0] == num_lines:
continue
Reported by Pylint.
Line: 95
Column: 17
with self.assertRaisesRegex(IndentationError,
"unindent does not match any "
"outer indentation level"):
for tok in tokenize(readline):
pass
def test_int(self):
# Ordinary integers and binary operators
self.check_tokenize("0xff <= 255", """\
Reported by Pylint.
Line: 222
Column: 45
def test_underscore_literals(self):
def number_token(s):
f = BytesIO(s.encode('utf-8'))
for toktype, token, start, end, line in tokenize(f.readline):
if toktype == NUMBER:
return token
return 'invalid token'
for lit in VALID_UNDERSCORE_LITERALS:
if '(' in lit:
Reported by Pylint.
Line: 222
Column: 26
def test_underscore_literals(self):
def number_token(s):
f = BytesIO(s.encode('utf-8'))
for toktype, token, start, end, line in tokenize(f.readline):
if toktype == NUMBER:
return token
return 'invalid token'
for lit in VALID_UNDERSCORE_LITERALS:
if '(' in lit:
Reported by Pylint.
Line: 222
Column: 33
def test_underscore_literals(self):
def number_token(s):
f = BytesIO(s.encode('utf-8'))
for toktype, token, start, end, line in tokenize(f.readline):
if toktype == NUMBER:
return token
return 'invalid token'
for lit in VALID_UNDERSCORE_LITERALS:
if '(' in lit:
Reported by Pylint.
Line: 222
Column: 40
def test_underscore_literals(self):
def number_token(s):
f = BytesIO(s.encode('utf-8'))
for toktype, token, start, end, line in tokenize(f.readline):
if toktype == NUMBER:
return token
return 'invalid token'
for lit in VALID_UNDERSCORE_LITERALS:
if '(' in lit:
Reported by Pylint.
Lib/idlelib/config.py
143 issues
Line: 50
Column: 36
self.file = cfgFile # This is currently '' when testing.
ConfigParser.__init__(self, defaults=cfgDefaults, strict=False)
def Get(self, section, option, type=None, default=None, raw=False):
"""
Get an option value for given section/option or return default.
If type is specified, return as type.
"""
# TODO Use default as fallback, at least if not None
Reported by Pylint.
Line: 55
Column: 3
Get an option value for given section/option or return default.
If type is specified, return as type.
"""
# TODO Use default as fallback, at least if not None
# Should also print Warning(file, section, option).
# Currently may raise ValueError
if not self.has_option(section, option):
return default
if type == 'bool':
Reported by Pylint.
Line: 160
Column: 3
self.config_types = ('main', 'highlight', 'keys', 'extensions')
self.defaultCfg = {}
self.userCfg = {}
self.cfg = {} # TODO use to select userCfg vs defaultCfg
# self.blink_off_time = <first editor text>['insertofftime']
# See https:/bugs.python.org/issue4630, msg356516.
if not _utest:
self.CreateConfigHandlers()
Reported by Pylint.
Line: 210
Column: 17
print(warn, file=sys.stderr)
except OSError:
pass
raise SystemExit
# TODO continue without userDIr instead of exit
return userDir
def GetOption(self, configType, section, option, default=None, type=None,
warn_on_default=True, raw=False):
Reported by Pylint.
Line: 211
Column: 3
except OSError:
pass
raise SystemExit
# TODO continue without userDIr instead of exit
return userDir
def GetOption(self, configType, section, option, default=None, type=None,
warn_on_default=True, raw=False):
"""Return a value for configType section option, or default.
Reported by Pylint.
Line: 214
Column: 68
# TODO continue without userDIr instead of exit
return userDir
def GetOption(self, configType, section, option, default=None, type=None,
warn_on_default=True, raw=False):
"""Return a value for configType section option, or default.
If type is not None, return a value of that type. Also pass raw
to the config parser. First try to return a valid value
Reported by Pylint.
Line: 289
Column: 28
back = theme_dict[element + '-background']
return {"foreground": fore, "background": back}
def GetThemeDict(self, type, themeName):
"""Return {option:value} dict for elements in themeName.
type - string, 'default' or 'user' theme type
themeName - string, theme name
Values are loaded over ultimate fallback defaults to guarantee
Reported by Pylint.
Line: 307
Column: 3
# element (other than cursor) even though some values are not
# yet used by idle, to allow for their use in the future.
# Default values are generally black and white.
# TODO copy theme from a class attribute.
theme ={'normal-foreground':'#000000',
'normal-background':'#ffffff',
'keyword-foreground':'#000000',
'keyword-background':'#ffffff',
'builtin-foreground':'#000000',
Reported by Pylint.
Line: 438
Column: 3
if self.GetOption('extensions', extn, 'enable', default=True,
type='bool'):
#the extension is enabled
if editor_only or shell_only: # TODO both True contradict
if editor_only:
option = "enable_editor"
else:
option = "enable_shell"
if self.GetOption('extensions', extn,option,
Reported by Pylint.
Line: 468
Column: 3
for extn in self.GetExtensions(active_only=0):
for event in self.GetExtensionKeys(extn):
if event == vEvent:
extName = extn # TODO return here?
return extName
def GetExtensionKeys(self, extensionName):
"""Return dict: {configurable extensionName event : active keybinding}.
Reported by Pylint.
Lib/test/test_struct.py
143 issues
Line: 17
Column: 26
integer_codes = 'b', 'B', 'h', 'H', 'i', 'I', 'l', 'L', 'q', 'Q', 'n', 'N'
byteorders = '', '@', '=', '<', '>', '!'
def iter_integer_formats(byteorders=byteorders):
for code in integer_codes:
for byteorder in byteorders:
if (byteorder not in ('', '@') and code in ('n', 'N')):
continue
yield code, byteorder
Reported by Pylint.
Line: 69
Column: 17
t = True
for prefix in ('', '@', '<', '>', '=', '!'):
for format in ('xcbhilfd?', 'xcBHILfd?'):
format = prefix + format
s = struct.pack(format, c, b, h, i, l, f, d, t)
cp, bp, hp, ip, lp, fp, dp, tp = struct.unpack(format, s)
self.assertEqual(cp, c)
self.assertEqual(bp, b)
Reported by Pylint.
Line: 146
Column: 13
# standard integer sizes
for code, byteorder in iter_integer_formats(('=', '<', '>', '!')):
format = byteorder+code
size = struct.calcsize(format)
self.assertEqual(size, expected_size[code])
# native integer sizes
native_pairs = 'bB', 'hH', 'iI', 'lL', 'nN', 'qQ'
Reported by Pylint.
Line: 174
Column: 32
import binascii
class IntTester(unittest.TestCase):
def __init__(self, format):
super(IntTester, self).__init__(methodName='test_one')
self.format = format
self.code = format[-1]
self.byteorder = format[:-1]
if not self.byteorder in byteorders:
Reported by Pylint.
Line: 200
Column: 17
unpack=struct.unpack,
unhexlify=binascii.unhexlify):
format = self.format
if self.min_value <= x <= self.max_value:
expected = x
if self.signed and x < 0:
expected += 1 << self.bitsize
self.assertGreaterEqual(expected, 0)
Reported by Pylint.
Line: 234
Column: 13
self.assertRaises((OverflowError, ValueError, struct.error),
pack, format, x)
def run(self):
from random import randrange
# Create all interesting powers of 2.
values = []
for exp in range(self.bitsize + 3):
Reported by Pylint.
Line: 243
Column: 21
values.append(1 << exp)
# Add some random values.
for i in range(self.bitsize):
val = 0
for j in range(self.bytesize):
val = (val << 8) | randrange(256)
values.append(val)
Reported by Pylint.
Line: 245
Column: 25
# Add some random values.
for i in range(self.bitsize):
val = 0
for j in range(self.bytesize):
val = (val << 8) | randrange(256)
values.append(val)
# Values absorbed from other tests
values.extend([300, 700000, sys.maxsize*4])
Reported by Pylint.
Line: 307
Column: 21
Indexable(42), Indexable(100), Indexable(127)):
try:
struct.pack(format, obj)
except:
self.fail("integer code pack failed on object "
"with '__index__' method")
# Check for bogus values from '__index__'.
for obj in (Indexable(b'a'), Indexable('b'), Indexable(None),
Reported by Pylint.
Line: 319
Column: 13
obj)
for code, byteorder in iter_integer_formats():
format = byteorder+code
t = IntTester(format)
t.run()
def test_nN_code(self):
# n and N don't exist in standard sizes
Reported by Pylint.
Lib/test/test_curses.py
142 issues
Line: 1118
Column: 27
try:
curses.unget_wch(ch)
except Exception as err:
self.fail("unget_wch(%a) failed with encoding %s: %s"
% (ch, stdscr.encoding, err))
read = stdscr.get_wch()
self.assertEqual(read, ch)
code = ord(ch)
Reported by Pylint.
Line: 120
Column: 3
@requires_curses_func('filter')
def test_filter(self):
# TODO: Should be called before initscr() or newterm() are called.
# TODO: nofilter()
curses.filter()
@requires_curses_func('use_env')
def test_use_env(self):
Reported by Pylint.
Line: 121
Column: 3
@requires_curses_func('filter')
def test_filter(self):
# TODO: Should be called before initscr() or newterm() are called.
# TODO: nofilter()
curses.filter()
@requires_curses_func('use_env')
def test_use_env(self):
# TODO: Should be called before initscr() or newterm() are called.
Reported by Pylint.
Line: 126
Column: 3
@requires_curses_func('use_env')
def test_use_env(self):
# TODO: Should be called before initscr() or newterm() are called.
# TODO: use_tioctl()
curses.use_env(False)
curses.use_env(True)
def test_create_windows(self):
Reported by Pylint.
Line: 127
Column: 3
@requires_curses_func('use_env')
def test_use_env(self):
# TODO: Should be called before initscr() or newterm() are called.
# TODO: use_tioctl()
curses.use_env(False)
curses.use_env(True)
def test_create_windows(self):
win = curses.newwin(5, 10)
Reported by Pylint.
Line: 338
Column: 3
def test_getch(self):
win = curses.newwin(5, 12, 5, 2)
# TODO: Test with real input by writing to master fd.
for c in 'spam\n'[::-1]:
curses.ungetch(c)
self.assertEqual(win.getch(3, 1), b's'[0])
self.assertEqual(win.getyx(), (3, 1))
self.assertEqual(win.getch(3, 4), b'p'[0])
Reported by Pylint.
Line: 358
Column: 3
self.assertRaises(ValueError, win.getstr, -400)
self.assertRaises(ValueError, win.getstr, 2, 3, -400)
# TODO: Test with real input by writing to master fd.
for c in 'Lorem\nipsum\ndolor\nsit\namet\n'[::-1]:
curses.ungetch(c)
self.assertEqual(win.getstr(3, 1, 2), b'Lo')
self.assertEqual(win.instr(3, 0), b' Lo ')
self.assertEqual(win.getstr(3, 5, 10), b'ipsum')
Reported by Pylint.
Line: 449
Column: 3
win.scrollok(False)
def test_attributes(self):
# TODO: attr_get(), attr_set(), ...
win = curses.newwin(5, 15, 5, 2)
win.attron(curses.A_BOLD)
win.attroff(curses.A_BOLD)
win.attrset(curses.A_BOLD)
Reported by Pylint.
Line: 646
Column: 3
self.assertEqual(win.inch(3, 1), b'a'[0])
def test_unctrl(self):
# TODO: wunctrl()
self.assertEqual(curses.unctrl(b'A'), b'A')
self.assertEqual(curses.unctrl('A'), b'A')
self.assertEqual(curses.unctrl(65), b'A')
self.assertEqual(curses.unctrl(b'\n'), b'^J')
self.assertEqual(curses.unctrl('\n'), b'^J')
Reported by Pylint.
Line: 704
Column: 3
curses.newpad(50, 50)
def test_env_queries(self):
# TODO: term_attrs(), erasewchar(), killwchar()
self.assertIsInstance(curses.termname(), bytes)
self.assertIsInstance(curses.longname(), bytes)
self.assertIsInstance(curses.baudrate(), int)
self.assertIsInstance(curses.has_ic(), bool)
self.assertIsInstance(curses.has_il(), bool)
Reported by Pylint.