The following issues were found
Lib/test/test_sunau.py
20 issues
Line: 1
Column: 1
import unittest
from test import audiotests
from audioop import byteswap
import io
import struct
import sys
import sunau
Reported by Pylint.
Line: 10
Column: 1
import sunau
class SunauTest(audiotests.AudioWriteTests,
audiotests.AudioTestsWithSourceFile):
module = sunau
class SunauPCM8Test(SunauTest, unittest.TestCase):
Reported by Pylint.
Line: 15
Column: 1
module = sunau
class SunauPCM8Test(SunauTest, unittest.TestCase):
sndfilename = 'pluck-pcm8.au'
sndfilenframes = 3307
nchannels = 2
sampwidth = 1
framerate = 11025
Reported by Pylint.
Line: 32
Column: 1
""")
class SunauPCM16Test(SunauTest, unittest.TestCase):
sndfilename = 'pluck-pcm16.au'
sndfilenframes = 3307
nchannels = 2
sampwidth = 2
framerate = 11025
Reported by Pylint.
Line: 51
Column: 1
""")
class SunauPCM24Test(SunauTest, unittest.TestCase):
sndfilename = 'pluck-pcm24.au'
sndfilenframes = 3307
nchannels = 2
sampwidth = 3
framerate = 11025
Reported by Pylint.
Line: 76
Column: 1
""")
class SunauPCM32Test(SunauTest, unittest.TestCase):
sndfilename = 'pluck-pcm32.au'
sndfilenframes = 3307
nchannels = 2
sampwidth = 4
framerate = 11025
Reported by Pylint.
Line: 101
Column: 1
""")
class SunauULAWTest(SunauTest, unittest.TestCase):
sndfilename = 'pluck-ulaw.au'
sndfilenframes = 3307
nchannels = 2
sampwidth = 2
framerate = 11025
Reported by Pylint.
Line: 122
Column: 1
frames = byteswap(frames, 2)
class SunauLowLevelTest(unittest.TestCase):
def test_read_bad_magic_number(self):
b = b'SPA'
with self.assertRaises(EOFError):
sunau.open(io.BytesIO(b))
Reported by Pylint.
Line: 124
Column: 5
class SunauLowLevelTest(unittest.TestCase):
def test_read_bad_magic_number(self):
b = b'SPA'
with self.assertRaises(EOFError):
sunau.open(io.BytesIO(b))
b = b'SPAM'
with self.assertRaisesRegex(sunau.Error, 'bad magic number'):
Reported by Pylint.
Line: 125
Column: 9
class SunauLowLevelTest(unittest.TestCase):
def test_read_bad_magic_number(self):
b = b'SPA'
with self.assertRaises(EOFError):
sunau.open(io.BytesIO(b))
b = b'SPAM'
with self.assertRaisesRegex(sunau.Error, 'bad magic number'):
sunau.open(io.BytesIO(b))
Reported by Pylint.
Lib/test/test_tools/test_md5sum.py
20 issues
Line: 45
Column: 18
self.assertFalse(err)
def test_dash_l(self):
rc, out, err = assert_python_ok(self.script, '-l', self.fodder)
self.assertEqual(rc, 0)
self.assertIn(self.fodder_md5, out)
parts = self.fodder.split(os.path.sep)
self.assertIn(parts[-1].encode(), out)
self.assertNotIn(parts[-2].encode(), out)
Reported by Pylint.
Line: 53
Column: 18
self.assertNotIn(parts[-2].encode(), out)
def test_dash_t(self):
rc, out, err = assert_python_ok(self.script, '-t', self.fodder)
self.assertEqual(rc, 0)
self.assertTrue(out.startswith(self.fodder_textmode_md5))
self.assertNotIn(self.fodder_md5, out)
def test_dash_s(self):
Reported by Pylint.
Line: 59
Column: 18
self.assertNotIn(self.fodder_md5, out)
def test_dash_s(self):
rc, out, err = assert_python_ok(self.script, '-s', '512', self.fodder)
self.assertEqual(rc, 0)
self.assertIn(self.fodder_md5, out)
def test_multiple_files(self):
rc, out, err = assert_python_ok(self.script, self.fodder, self.fodder)
Reported by Pylint.
Line: 64
Column: 18
self.assertIn(self.fodder_md5, out)
def test_multiple_files(self):
rc, out, err = assert_python_ok(self.script, self.fodder, self.fodder)
self.assertEqual(rc, 0)
lines = out.splitlines()
self.assertEqual(len(lines), 2)
self.assertEqual(*lines)
Reported by Pylint.
Line: 14
Column: 1
skip_if_missing()
@hashlib_helper.requires_hashdigest('md5')
class MD5SumTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.script = os.path.join(scriptsdir, 'md5sum.py')
os.mkdir(os_helper.TESTFN)
cls.fodder = os.path.join(os_helper.TESTFN, 'md5sum.fodder')
Reported by Pylint.
Line: 20
Column: 40
cls.script = os.path.join(scriptsdir, 'md5sum.py')
os.mkdir(os_helper.TESTFN)
cls.fodder = os.path.join(os_helper.TESTFN, 'md5sum.fodder')
with open(cls.fodder, 'wb') as f:
f.write(b'md5sum\r\ntest file\r\n')
cls.fodder_md5 = b'd38dae2eb1ab346a292ef6850f9e1a0d'
cls.fodder_textmode_md5 = b'a8b07894e2ca3f2a4c3094065fa6e0a5'
@classmethod
Reported by Pylint.
Line: 29
Column: 5
def tearDownClass(cls):
os_helper.rmtree(os_helper.TESTFN)
def test_noargs(self):
rc, out, err = assert_python_ok(self.script)
self.assertEqual(rc, 0)
self.assertTrue(
out.startswith(b'd41d8cd98f00b204e9800998ecf8427e <stdin>'))
self.assertFalse(err)
Reported by Pylint.
Line: 30
Column: 9
os_helper.rmtree(os_helper.TESTFN)
def test_noargs(self):
rc, out, err = assert_python_ok(self.script)
self.assertEqual(rc, 0)
self.assertTrue(
out.startswith(b'd41d8cd98f00b204e9800998ecf8427e <stdin>'))
self.assertFalse(err)
Reported by Pylint.
Line: 36
Column: 5
out.startswith(b'd41d8cd98f00b204e9800998ecf8427e <stdin>'))
self.assertFalse(err)
def test_checksum_fodder(self):
rc, out, err = assert_python_ok(self.script, self.fodder)
self.assertEqual(rc, 0)
self.assertTrue(out.startswith(self.fodder_md5))
for part in self.fodder.split(os.path.sep):
self.assertIn(part.encode(), out)
Reported by Pylint.
Line: 37
Column: 9
self.assertFalse(err)
def test_checksum_fodder(self):
rc, out, err = assert_python_ok(self.script, self.fodder)
self.assertEqual(rc, 0)
self.assertTrue(out.startswith(self.fodder_md5))
for part in self.fodder.split(os.path.sep):
self.assertIn(part.encode(), out)
self.assertFalse(err)
Reported by Pylint.
Tools/scripts/patchcheck.py
20 issues
Line: 32
Column: 1
def status(message, modal=False, info=None):
"""Decorator to output status info to stdout."""
def decorated_fxn(fxn):
def call_fxn(*args, **kwargs):
sys.stdout.write(message + ' ... ')
sys.stdout.flush()
result = fxn(*args, **kwargs)
if not modal and not info:
print("done")
Reported by Pylint.
Line: 136
Column: 17
for line in st.stdout:
line = line.decode().rstrip()
status_text, filename = line.split(maxsplit=1)
status = set(status_text)
# modified, added or unmerged files
if not status.intersection('MAU'):
continue
if ' -> ' in filename:
# file is renamed
Reported by Pylint.
Line: 209
Column: 16
with open(abspath, 'wb') as f:
f.writelines(new_lines)
fixed.append(path)
except Exception as err:
print('Cannot fix %s: %s' % (path, err))
return fixed
@status("Docs modified", modal=True)
Reported by Pylint.
Line: 7
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import sys
import shutil
import os.path
import subprocess
import sysconfig
import reindent
import untabify
Reported by Bandit.
Line: 51
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
"""Get the symbolic name for the current git branch"""
cmd = "git rev-parse --abbrev-ref HEAD".split()
try:
return subprocess.check_output(cmd,
stderr=subprocess.DEVNULL,
cwd=SRCDIR,
encoding='UTF-8')
except subprocess.CalledProcessError:
return None
Reported by Bandit.
Line: 66
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
"""
cmd = "git remote get-url upstream".split()
try:
subprocess.check_output(cmd,
stderr=subprocess.DEVNULL,
cwd=SRCDIR,
encoding='UTF-8')
except subprocess.CalledProcessError:
return "origin"
Reported by Bandit.
Line: 84
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
env = os.environ.copy()
env['LANG'] = 'C'
try:
remote_info = subprocess.check_output(cmd,
stderr=subprocess.DEVNULL,
cwd=SRCDIR,
encoding='UTF-8',
env=env)
except subprocess.CalledProcessError:
Reported by Bandit.
Line: 100
Column: 1
@status("Getting base branch for PR",
info=lambda x: x if x is not None else "not a PR branch")
def get_base_branch():
if not os.path.exists(os.path.join(SRCDIR, '.git')):
# Not a git checkout, so there's no base branch
return None
upstream_remote = get_git_upstream_remote()
version = sys.version_info
Reported by Pylint.
Line: 130
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
else:
cmd = 'git status --porcelain'
filenames = []
with subprocess.Popen(cmd.split(),
stdout=subprocess.PIPE,
cwd=SRCDIR) as st:
for line in st.stdout:
line = line.decode().rstrip()
status_text, filename = line.split(maxsplit=1)
Reported by Bandit.
Line: 132
Column: 46
filenames = []
with subprocess.Popen(cmd.split(),
stdout=subprocess.PIPE,
cwd=SRCDIR) as st:
for line in st.stdout:
line = line.decode().rstrip()
status_text, filename = line.split(maxsplit=1)
status = set(status_text)
# modified, added or unmerged files
Reported by Pylint.
Tools/scripts/highlight.py
20 issues
Line: 27
Column: 20
rows = [lines[srow-1][scol:]] + lines[srow: erow-1] + [lines[erow-1][:ecol]]
return ''.join(rows), end
def analyze_python(source):
'''Generate and classify chunks of Python for syntax highlighting.
Yields tuples in the form: (category, categorized_text).
'''
lines = source.splitlines(True)
lines.append('')
Reported by Pylint.
Line: 39
Column: 56
written = (1, 0)
for tok in tokenize.generate_tokens(readline):
prev_tok_type, prev_tok_str = tok_type, tok_str
tok_type, tok_str, (srow, scol), (erow, ecol), logical_lineno = tok
kind = ''
if tok_type == tokenize.COMMENT:
kind = 'comment'
elif tok_type == tokenize.OP and tok_str[:1] not in '{}[](),.:;@':
kind = 'operator'
Reported by Pylint.
Line: 68
Column: 19
#### Raw Output ###########################################
def raw_highlight(classified_text):
'Straight text display of text classifications'
result = []
for kind, text in classified_text:
result.append('%15s: %r\n' % (kind or 'plain', text))
return ''.join(result)
Reported by Pylint.
Line: 88
Column: 1
'operator': ('\033[0;33m', '\033[0m'),
}
def ansi_highlight(classified_text, colors=default_ansi):
'Add syntax highlighting to source code using ANSI escape sequences'
# http://en.wikipedia.org/wiki/ANSI_escape_code
result = []
for kind, text in classified_text:
opener, closer = colors.get(kind, ('', ''))
Reported by Pylint.
Line: 88
Column: 20
'operator': ('\033[0;33m', '\033[0m'),
}
def ansi_highlight(classified_text, colors=default_ansi):
'Add syntax highlighting to source code using ANSI escape sequences'
# http://en.wikipedia.org/wiki/ANSI_escape_code
result = []
for kind, text in classified_text:
opener, closer = colors.get(kind, ('', ''))
Reported by Pylint.
Line: 99
Column: 20
#### HTML Output ###########################################
def html_highlight(classified_text,opener='<pre class="python">\n', closer='</pre>\n'):
'Convert classified text to an HTML fragment'
result = [opener]
for kind, text in classified_text:
if kind:
result.append('<span class="%s">' % kind)
Reported by Pylint.
Line: 139
Column: 1
</html>
'''
def build_html_page(classified_text, title='python',
css=default_css, html=default_html):
'Create a complete HTML page with colorized source code'
css_str = '\n'.join(['%s %s' % item for item in css.items()])
result = html_highlight(classified_text)
title = html_module.escape(title)
Reported by Pylint.
Line: 139
Column: 21
</html>
'''
def build_html_page(classified_text, title='python',
css=default_css, html=default_html):
'Create a complete HTML page with colorized source code'
css_str = '\n'.join(['%s %s' % item for item in css.items()])
result = html_highlight(classified_text)
title = html_module.escape(title)
Reported by Pylint.
Line: 181
Column: 21
xlat = {'{': r'\{', '}': r'\}', '\\': r'\textbackslash{}'}
return re.sub(r'[\\{}]', lambda mo: xlat[mo.group()], s)
def latex_highlight(classified_text, title = 'python',
commands = default_latex_commands,
document = default_latex_document):
'Create a complete LaTeX document with colorized source code'
macros = '\n'.join(r'\newcommand{\py%s}[1]{%s}' % c for c in commands.items())
result = []
Reported by Pylint.
Line: 181
Column: 1
xlat = {'{': r'\{', '}': r'\}', '\\': r'\textbackslash{}'}
return re.sub(r'[\\{}]', lambda mo: xlat[mo.group()], s)
def latex_highlight(classified_text, title = 'python',
commands = default_latex_commands,
document = default_latex_document):
'Create a complete LaTeX document with colorized source code'
macros = '\n'.join(r'\newcommand{\py%s}[1]{%s}' % c for c in commands.items())
result = []
Reported by Pylint.
Lib/test/support/socket_helper.py
20 issues
Line: 7
Column: 1
import unittest
import sys
from .. import support
HOST = "localhost"
HOSTv4 = "127.0.0.1"
HOSTv6 = "::1"
Reported by Pylint.
Line: 109
Column: 48
# under an older kernel that does not support SO_REUSEPORT.
pass
if hasattr(socket, 'SO_EXCLUSIVEADDRUSE'):
sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1)
sock.bind((host, 0))
port = sock.getsockname()[1]
return port
Reported by Pylint.
Line: 149
Column: 9
return unittest.skip('No UNIX Sockets')(test)
global _bind_nix_socket_error
if _bind_nix_socket_error is None:
from .os_helper import TESTFN, unlink
path = TESTFN + "can_bind_unix_socket"
with socket.socket(socket.AF_UNIX) as sock:
try:
sock.bind(path)
_bind_nix_socket_error = False
Reported by Pylint.
Line: 122
Column: 9
sock.bind(addr)
except PermissionError:
sock.close()
raise unittest.SkipTest('cannot bind AF_UNIX sockets')
def _is_ipv6_enabled():
"""Check whether IPv6 is enabled on this host."""
if socket.has_ipv6:
sock = None
Reported by Pylint.
Line: 147
Column: 5
"""Decorator for tests requiring a functional bind() for unix sockets."""
if not hasattr(socket, 'AF_UNIX'):
return unittest.skip('No UNIX Sockets')(test)
global _bind_nix_socket_error
if _bind_nix_socket_error is None:
from .os_helper import TESTFN, unlink
path = TESTFN + "can_bind_unix_socket"
with socket.socket(socket.AF_UNIX) as sock:
try:
Reported by Pylint.
Line: 266
Column: 3
break
filter_error(err)
raise
# XXX should we catch generic exceptions and look for their
# __cause__ or __context__?
finally:
socket.setdefaulttimeout(old_timeout)
Reported by Pylint.
Line: 1
Column: 1
import contextlib
import errno
import socket
import unittest
import sys
from .. import support
Reported by Pylint.
Line: 11
Column: 1
HOST = "localhost"
HOSTv4 = "127.0.0.1"
HOSTv6 = "::1"
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
"""Returns an unused port that should be suitable for binding. This is
Reported by Pylint.
Line: 12
Column: 1
HOST = "localhost"
HOSTv4 = "127.0.0.1"
HOSTv6 = "::1"
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
"""Returns an unused port that should be suitable for binding. This is
achieved by creating a temporary socket with the same family and type as
Reported by Pylint.
Line: 117
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def bind_unix_socket(sock, addr):
"""Bind a unix socket, raising SkipTest if PermissionError is raised."""
assert sock.family == socket.AF_UNIX
try:
sock.bind(addr)
except PermissionError:
sock.close()
raise unittest.SkipTest('cannot bind AF_UNIX sockets')
Reported by Bandit.
Lib/test/test_importlib/test_zip.py
20 issues
Line: 82
Column: 16
def test_normalized_name(self):
dist = distribution('example')
assert dist._normalized_name == 'example'
Reported by Pylint.
Line: 1
Column: 1
import sys
import unittest
from contextlib import ExitStack
from importlib.metadata import (
PackageNotFoundError,
distribution,
distributions,
entry_points,
Reported by Pylint.
Line: 19
Column: 1
@requires_zlib()
class TestZip(unittest.TestCase):
root = 'test.test_importlib.data'
def _fixture_on_path(self, filename):
pkg_file = resources.files(self.root).joinpath(filename)
file = self.resources.enter_context(resources.as_file(pkg_file))
Reported by Pylint.
Line: 25
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def _fixture_on_path(self, filename):
pkg_file = resources.files(self.root).joinpath(filename)
file = self.resources.enter_context(resources.as_file(pkg_file))
assert file.name.startswith('example-'), file.name
sys.path.insert(0, str(file))
self.resources.callback(sys.path.pop, 0)
def setUp(self):
# Find the path to the example-*.whl so we can add it to the front of
Reported by Bandit.
Line: 36
Column: 5
self.addCleanup(self.resources.close)
self._fixture_on_path('example-21.12-py3-none-any.whl')
def test_zip_version(self):
self.assertEqual(version('example'), '21.12')
def test_zip_version_does_not_match(self):
with self.assertRaises(PackageNotFoundError):
version('definitely-not-installed')
Reported by Pylint.
Line: 39
Column: 5
def test_zip_version(self):
self.assertEqual(version('example'), '21.12')
def test_zip_version_does_not_match(self):
with self.assertRaises(PackageNotFoundError):
version('definitely-not-installed')
def test_zip_entry_points(self):
scripts = entry_points(group='console_scripts')
Reported by Pylint.
Line: 43
Column: 5
with self.assertRaises(PackageNotFoundError):
version('definitely-not-installed')
def test_zip_entry_points(self):
scripts = entry_points(group='console_scripts')
entry_point = scripts['example']
self.assertEqual(entry_point.value, 'example:main')
entry_point = scripts['Example']
self.assertEqual(entry_point.value, 'example:main')
Reported by Pylint.
Line: 50
Column: 5
entry_point = scripts['Example']
self.assertEqual(entry_point.value, 'example:main')
def test_missing_metadata(self):
self.assertIsNone(distribution('example').read_text('does not exist'))
def test_case_insensitive(self):
self.assertEqual(version('Example'), '21.12')
Reported by Pylint.
Line: 53
Column: 5
def test_missing_metadata(self):
self.assertIsNone(distribution('example').read_text('does not exist'))
def test_case_insensitive(self):
self.assertEqual(version('Example'), '21.12')
def test_files(self):
for file in files('example'):
path = str(file.dist.locate_file(file))
Reported by Pylint.
Line: 56
Column: 5
def test_case_insensitive(self):
self.assertEqual(version('Example'), '21.12')
def test_files(self):
for file in files('example'):
path = str(file.dist.locate_file(file))
assert '.whl/' in path, path
def test_one_distribution(self):
Reported by Pylint.
Lib/test/libregrtest/win_utils.py
20 issues
Line: 1
Column: 1
import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning
Reported by Pylint.
Line: 3
Column: 1
import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning
Reported by Pylint.
Line: 7
Column: 1
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning
# Max size of asynchronous reads
Reported by Pylint.
Line: 124
Column: 9
def _read_lines(self):
overlapped, _ = _winapi.ReadFile(self.pipe, BUFSIZE, True)
bytes_read, res = overlapped.GetOverlappedResult(False)
if res != 0:
return ()
output = overlapped.getbuffer()
output = output.decode('oem', 'replace')
Reported by Pylint.
Line: 1
Column: 1
import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning
Reported by Pylint.
Line: 2
Column: 1
import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning
Reported by Pylint.
Line: 3
Column: 1
import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning
Reported by Pylint.
Line: 4
Column: 1
import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning
Reported by Pylint.
Line: 5
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning
Reported by Bandit.
Line: 5
Column: 1
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning
Reported by Pylint.
Lib/test/test_colorsys.py
20 issues
Line: 1
Column: 1
import unittest
import colorsys
def frange(start, stop, step):
while start <= stop:
yield start
start += step
class ColorsysTest(unittest.TestCase):
Reported by Pylint.
Line: 4
Column: 1
import unittest
import colorsys
def frange(start, stop, step):
while start <= stop:
yield start
start += step
class ColorsysTest(unittest.TestCase):
Reported by Pylint.
Line: 9
Column: 1
yield start
start += step
class ColorsysTest(unittest.TestCase):
def assertTripleEqual(self, tr1, tr2):
self.assertEqual(len(tr1), 3)
self.assertEqual(len(tr2), 3)
self.assertAlmostEqual(tr1[0], tr2[0])
Reported by Pylint.
Line: 11
Column: 5
class ColorsysTest(unittest.TestCase):
def assertTripleEqual(self, tr1, tr2):
self.assertEqual(len(tr1), 3)
self.assertEqual(len(tr2), 3)
self.assertAlmostEqual(tr1[0], tr2[0])
self.assertAlmostEqual(tr1[1], tr2[1])
self.assertAlmostEqual(tr1[2], tr2[2])
Reported by Pylint.
Line: 11
Column: 5
class ColorsysTest(unittest.TestCase):
def assertTripleEqual(self, tr1, tr2):
self.assertEqual(len(tr1), 3)
self.assertEqual(len(tr2), 3)
self.assertAlmostEqual(tr1[0], tr2[0])
self.assertAlmostEqual(tr1[1], tr2[1])
self.assertAlmostEqual(tr1[2], tr2[2])
Reported by Pylint.
Line: 18
Column: 5
self.assertAlmostEqual(tr1[1], tr2[1])
self.assertAlmostEqual(tr1[2], tr2[2])
def test_hsv_roundtrip(self):
for r in frange(0.0, 1.0, 0.2):
for g in frange(0.0, 1.0, 0.2):
for b in frange(0.0, 1.0, 0.2):
rgb = (r, g, b)
self.assertTripleEqual(
Reported by Pylint.
Line: 19
Column: 13
self.assertAlmostEqual(tr1[2], tr2[2])
def test_hsv_roundtrip(self):
for r in frange(0.0, 1.0, 0.2):
for g in frange(0.0, 1.0, 0.2):
for b in frange(0.0, 1.0, 0.2):
rgb = (r, g, b)
self.assertTripleEqual(
rgb,
Reported by Pylint.
Line: 20
Column: 17
def test_hsv_roundtrip(self):
for r in frange(0.0, 1.0, 0.2):
for g in frange(0.0, 1.0, 0.2):
for b in frange(0.0, 1.0, 0.2):
rgb = (r, g, b)
self.assertTripleEqual(
rgb,
colorsys.hsv_to_rgb(*colorsys.rgb_to_hsv(*rgb))
Reported by Pylint.
Line: 21
Column: 21
def test_hsv_roundtrip(self):
for r in frange(0.0, 1.0, 0.2):
for g in frange(0.0, 1.0, 0.2):
for b in frange(0.0, 1.0, 0.2):
rgb = (r, g, b)
self.assertTripleEqual(
rgb,
colorsys.hsv_to_rgb(*colorsys.rgb_to_hsv(*rgb))
)
Reported by Pylint.
Line: 28
Column: 5
colorsys.hsv_to_rgb(*colorsys.rgb_to_hsv(*rgb))
)
def test_hsv_values(self):
values = [
# rgb, hsv
((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black
((0.0, 0.0, 1.0), (4./6., 1.0, 1.0)), # blue
((0.0, 1.0, 0.0), (2./6., 1.0, 1.0)), # green
Reported by Pylint.
Lib/netrc.py
20 issues
Line: 5
Column: 1
# Module and documentation by Eric S. Raymond, 21 Dec 1998
import os, shlex, stat
__all__ = ["netrc", "NetrcParseError"]
class NetrcParseError(Exception):
Reported by Pylint.
Line: 22
Column: 1
return "%s (%s, line %s)" % (self.msg, self.filename, self.lineno)
class netrc:
def __init__(self, file=None):
default_netrc = file is None
if file is None:
file = os.path.join(os.path.expanduser("~"), ".netrc")
self.hosts = {}
Reported by Pylint.
Line: 22
Column: 1
return "%s (%s, line %s)" % (self.msg, self.filename, self.lineno)
class netrc:
def __init__(self, file=None):
default_netrc = file is None
if file is None:
file = os.path.join(os.path.expanduser("~"), ".netrc")
self.hosts = {}
Reported by Pylint.
Line: 30
Column: 50
self.hosts = {}
self.macros = {}
try:
with open(file, encoding="utf-8") as fp:
self._parse(file, fp, default_netrc)
except UnicodeDecodeError:
with open(file, encoding="locale") as fp:
self._parse(file, fp, default_netrc)
Reported by Pylint.
Line: 33
Column: 51
with open(file, encoding="utf-8") as fp:
self._parse(file, fp, default_netrc)
except UnicodeDecodeError:
with open(file, encoding="locale") as fp:
self._parse(file, fp, default_netrc)
def _parse(self, file, fp, default_netrc):
lexer = shlex.shlex(fp)
lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
Reported by Pylint.
Line: 36
Column: 5
with open(file, encoding="locale") as fp:
self._parse(file, fp, default_netrc)
def _parse(self, file, fp, default_netrc):
lexer = shlex.shlex(fp)
lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
lexer.commenters = lexer.commenters.replace('#', '')
while 1:
# Look for a machine, default, or macdef top-level keyword
Reported by Pylint.
Line: 36
Column: 5
with open(file, encoding="locale") as fp:
self._parse(file, fp, default_netrc)
def _parse(self, file, fp, default_netrc):
lexer = shlex.shlex(fp)
lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
lexer.commenters = lexer.commenters.replace('#', '')
while 1:
# Look for a machine, default, or macdef top-level keyword
Reported by Pylint.
Line: 36
Column: 5
with open(file, encoding="locale") as fp:
self._parse(file, fp, default_netrc)
def _parse(self, file, fp, default_netrc):
lexer = shlex.shlex(fp)
lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
lexer.commenters = lexer.commenters.replace('#', '')
while 1:
# Look for a machine, default, or macdef top-level keyword
Reported by Pylint.
Line: 36
Column: 5
with open(file, encoding="locale") as fp:
self._parse(file, fp, default_netrc)
def _parse(self, file, fp, default_netrc):
lexer = shlex.shlex(fp)
lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
lexer.commenters = lexer.commenters.replace('#', '')
while 1:
# Look for a machine, default, or macdef top-level keyword
Reported by Pylint.
Line: 40
Column: 9
lexer = shlex.shlex(fp)
lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
lexer.commenters = lexer.commenters.replace('#', '')
while 1:
# Look for a machine, default, or macdef top-level keyword
saved_lineno = lexer.lineno
toplevel = tt = lexer.get_token()
if not tt:
break
Reported by Pylint.
Lib/test/test_json/test_speedups.py
20 issues
Line: 6
Column: 9
class BadBool:
def __bool__(self):
1/0
class TestSpeedups(CTest):
def test_scanstring(self):
self.assertEqual(self.json.decoder.scanstring.__module__, "_json")
Reported by Pylint.
Line: 44
Column: 1
def test_bad_str_encoder(self):
# Issue #31505: There shouldn't be an assertion failure in case
# c_make_encoder() receives a bad encoder() argument.
def bad_encoder1(*args):
return None
enc = self.json.encoder.c_make_encoder(None, lambda obj: str(obj),
bad_encoder1, None, ': ', ', ',
False, False, False)
with self.assertRaises(TypeError):
Reported by Pylint.
Line: 46
Column: 54
# c_make_encoder() receives a bad encoder() argument.
def bad_encoder1(*args):
return None
enc = self.json.encoder.c_make_encoder(None, lambda obj: str(obj),
bad_encoder1, None, ': ', ', ',
False, False, False)
with self.assertRaises(TypeError):
enc('spam', 4)
with self.assertRaises(TypeError):
Reported by Pylint.
Line: 54
Column: 1
with self.assertRaises(TypeError):
enc({'spam': 42}, 4)
def bad_encoder2(*args):
1/0
enc = self.json.encoder.c_make_encoder(None, lambda obj: str(obj),
bad_encoder2, None, ': ', ', ',
False, False, False)
with self.assertRaises(ZeroDivisionError):
Reported by Pylint.
Line: 55
Column: 13
enc({'spam': 42}, 4)
def bad_encoder2(*args):
1/0
enc = self.json.encoder.c_make_encoder(None, lambda obj: str(obj),
bad_encoder2, None, ': ', ', ',
False, False, False)
with self.assertRaises(ZeroDivisionError):
enc('spam', 4)
Reported by Pylint.
Line: 56
Column: 54
def bad_encoder2(*args):
1/0
enc = self.json.encoder.c_make_encoder(None, lambda obj: str(obj),
bad_encoder2, None, ': ', ', ',
False, False, False)
with self.assertRaises(ZeroDivisionError):
enc('spam', 4)
Reported by Pylint.
Line: 1
Column: 1
from test.test_json import CTest
class BadBool:
def __bool__(self):
1/0
class TestSpeedups(CTest):
Reported by Pylint.
Line: 4
Column: 1
from test.test_json import CTest
class BadBool:
def __bool__(self):
1/0
class TestSpeedups(CTest):
Reported by Pylint.
Line: 4
Column: 1
from test.test_json import CTest
class BadBool:
def __bool__(self):
1/0
class TestSpeedups(CTest):
Reported by Pylint.
Line: 9
Column: 1
1/0
class TestSpeedups(CTest):
def test_scanstring(self):
self.assertEqual(self.json.decoder.scanstring.__module__, "_json")
self.assertIs(self.json.decoder.scanstring, self.json.decoder.c_scanstring)
def test_encode_basestring_ascii(self):
Reported by Pylint.