The following issues were found
Lib/asyncio/format_helpers.py
5 issues
Line: 5
Column: 1
import inspect
import reprlib
import sys
import traceback
from . import constants
def _get_function_source(func):
Reported by Pylint.
Line: 7
Column: 1
import sys
import traceback
from . import constants
def _get_function_source(func):
func = inspect.unwrap(func)
if inspect.isfunction(func):
Reported by Pylint.
Line: 67
Column: 13
necessary work for asyncio debug mode.
"""
if f is None:
f = sys._getframe().f_back
if limit is None:
# Limit the amount of work to a reasonable amount, as extract_stack()
# can be called for each coroutine and future in debug mode.
limit = constants.DEBUG_STACK_DEPTH
stack = traceback.StackSummary.extract(traceback.walk_stack(f),
Reported by Pylint.
Line: 1
Column: 1
import functools
import inspect
import reprlib
import sys
import traceback
from . import constants
Reported by Pylint.
Line: 62
Column: 1
return func_repr
def extract_stack(f=None, limit=None):
"""Replacement for traceback.extract_stack() that only does the
necessary work for asyncio debug mode.
"""
if f is None:
f = sys._getframe().f_back
Reported by Pylint.
Lib/lib2to3/fixes/fix_repr.py
5 issues
Line: 7
Column: 1
"""Fixer that transforms `xyzzy` into repr(xyzzy)."""
# Local imports
from .. import fixer_base
from ..fixer_util import Call, Name, parenthesize
class FixRepr(fixer_base.BaseFix):
Reported by Pylint.
Line: 8
Column: 1
# Local imports
from .. import fixer_base
from ..fixer_util import Call, Name, parenthesize
class FixRepr(fixer_base.BaseFix):
BM_compatible = True
Reported by Pylint.
Line: 11
Column: 1
from ..fixer_util import Call, Name, parenthesize
class FixRepr(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
atom < '`' expr=any '`' >
"""
Reported by Pylint.
Line: 11
Column: 1
from ..fixer_util import Call, Name, parenthesize
class FixRepr(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
atom < '`' expr=any '`' >
"""
Reported by Pylint.
Line: 18
Column: 5
atom < '`' expr=any '`' >
"""
def transform(self, node, results):
expr = results["expr"].clone()
if expr.type == self.syms.testlist1:
expr = parenthesize(expr)
return Call(Name("repr"), [expr], prefix=node.prefix)
Reported by Pylint.
Lib/email/base64mime.py
5 issues
Line: 50
Column: 19
# Helpers
def header_length(bytearray):
"""Return the length of s when it is encoded with base64."""
groups_of_3, leftover = divmod(len(bytearray), 3)
# 4 bytes out for each 3 bytes (or nonzero fraction thereof) in.
n = groups_of_3 * 4
if leftover:
Reported by Pylint.
Line: 54
Column: 5
"""Return the length of s when it is encoded with base64."""
groups_of_3, leftover = divmod(len(bytearray), 3)
# 4 bytes out for each 3 bytes (or nonzero fraction thereof) in.
n = groups_of_3 * 4
if leftover:
n += 4
return n
Reported by Pylint.
Line: 56
Column: 9
# 4 bytes out for each 3 bytes (or nonzero fraction thereof) in.
n = groups_of_3 * 4
if leftover:
n += 4
return n
def header_encode(header_bytes, charset='iso-8859-1'):
Reported by Pylint.
Line: 76
Column: 1
def body_encode(s, maxlinelen=76, eol=NL):
r"""Encode a string with base64.
Each line will be wrapped at, at most, maxlinelen characters (defaults to
76 characters).
Reported by Pylint.
Line: 109
Column: 5
base64 (like =?iso-8859-1?b?bmloISBuaWgh?=) -- please use the high
level email.header class for that functionality.
"""
if not string:
return bytes()
elif isinstance(string, str):
return a2b_base64(string.encode('raw-unicode-escape'))
else:
return a2b_base64(string)
Reported by Pylint.
Lib/dbm/gnu.py
5 issues
Line: 3
Column: 1
"""Provide the _gdbm module as a dbm submodule."""
from _gdbm import *
Reported by Pylint.
Line: 3
Column: 1
"""Provide the _gdbm module as a dbm submodule."""
from _gdbm import *
Reported by Pylint.
Line: 3
Column: 1
"""Provide the _gdbm module as a dbm submodule."""
from _gdbm import *
Reported by Pylint.
Line: 3
Column: 1
"""Provide the _gdbm module as a dbm submodule."""
from _gdbm import *
Reported by Pylint.
Line: 3
Column: 1
"""Provide the _gdbm module as a dbm submodule."""
from _gdbm import *
Reported by Pylint.
Lib/idlelib/autoexpand.py
5 issues
Line: 27
Column: 33
self.bell = self.text.bell
self.state = None
def expand_word_event(self, event):
"Replace the current word with the next expansion."
curinsert = self.text.index("insert")
curline = self.text.get("insert linestart", "insert lineend")
if not self.state:
words = self.getwords()
Reported by Pylint.
Line: 68
Column: 9
if not wbefore and not wafter:
return []
words = []
dict = {}
# search backwards through words before
wbefore.reverse()
for w in wbefore:
if dict.get(w):
continue
Reported by Pylint.
Line: 19
Column: 1
import string
class AutoExpand:
wordchars = string.ascii_letters + string.digits + "_"
def __init__(self, editwin):
self.text = editwin.text
self.bell = self.text.bell
Reported by Pylint.
Line: 71
Column: 13
dict = {}
# search backwards through words before
wbefore.reverse()
for w in wbefore:
if dict.get(w):
continue
words.append(w)
dict[w] = w
# search onwards through words after
Reported by Pylint.
Line: 77
Column: 13
words.append(w)
dict[w] = w
# search onwards through words after
for w in wafter:
if dict.get(w):
continue
words.append(w)
dict[w] = w
words.append(word)
Reported by Pylint.
Lib/distutils/command/install_headers.py
5 issues
Line: 9
Column: 3
from distutils.core import Command
# XXX force is never used
class install_headers(Command):
description = "install C/C++ header files"
user_options = [('install-dir=', 'd',
Reported by Pylint.
Line: 10
Column: 1
# XXX force is never used
class install_headers(Command):
description = "install C/C++ header files"
user_options = [('install-dir=', 'd',
"directory to install header files to"),
Reported by Pylint.
Line: 10
Column: 1
# XXX force is never used
class install_headers(Command):
description = "install C/C++ header files"
user_options = [('install-dir=', 'd',
"directory to install header files to"),
Reported by Pylint.
Line: 43
Column: 5
(out, _) = self.copy_file(header, self.install_dir)
self.outfiles.append(out)
def get_inputs(self):
return self.distribution.headers or []
def get_outputs(self):
return self.outfiles
Reported by Pylint.
Line: 46
Column: 5
def get_inputs(self):
return self.distribution.headers or []
def get_outputs(self):
return self.outfiles
Reported by Pylint.
Lib/distutils/tests/test_extension.py
5 issues
Line: 10
Column: 1
from test.support.warnings_helper import check_warnings
from distutils.extension import read_setup_file, Extension
class ExtensionTestCase(unittest.TestCase):
def test_read_setup_file(self):
# trying to read a Setup file
# (sample extracted from the PyGame project)
setup = os.path.join(os.path.dirname(__file__), 'Setup.sample')
Reported by Pylint.
Line: 12
Column: 5
class ExtensionTestCase(unittest.TestCase):
def test_read_setup_file(self):
# trying to read a Setup file
# (sample extracted from the PyGame project)
setup = os.path.join(os.path.dirname(__file__), 'Setup.sample')
exts = read_setup_file(setup)
Reported by Pylint.
Line: 34
Column: 5
self.assertEqual(names, wanted)
def test_extension_init(self):
# the first argument, which is the name, must be a string
self.assertRaises(AssertionError, Extension, 1, [])
ext = Extension('name', [])
self.assertEqual(ext.name, 'name')
Reported by Pylint.
Line: 58
Column: 34
self.assertEqual(ext.optional, None)
# if there are unknown keyword options, warn about them
with check_warnings() as w:
warnings.simplefilter('always')
ext = Extension('name', ['file1', 'file2'], chic=True)
self.assertEqual(len(w.warnings), 1)
self.assertEqual(str(w.warnings[0].message),
Reported by Pylint.
Line: 66
Column: 1
self.assertEqual(str(w.warnings[0].message),
"Unknown Extension options: 'chic'")
def test_suite():
return unittest.makeSuite(ExtensionTestCase)
if __name__ == "__main__":
run_unittest(test_suite())
Reported by Pylint.
Lib/idlelib/idle_test/test_calltip_w.py
5 issues
Line: 4
Column: 1
"Test calltip_w, coverage 18%."
from idlelib import calltip_w
import unittest
from test.support import requires
from tkinter import Tk, Text
class CallTipWindowTest(unittest.TestCase):
Reported by Pylint.
Line: 5
Column: 1
from idlelib import calltip_w
import unittest
from test.support import requires
from tkinter import Tk, Text
class CallTipWindowTest(unittest.TestCase):
Reported by Pylint.
Line: 6
Column: 1
from idlelib import calltip_w
import unittest
from test.support import requires
from tkinter import Tk, Text
class CallTipWindowTest(unittest.TestCase):
@classmethod
Reported by Pylint.
Line: 9
Column: 1
from tkinter import Tk, Text
class CallTipWindowTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
requires('gui')
cls.root = Tk()
Reported by Pylint.
Line: 25
Column: 5
cls.root.destroy()
del cls.text, cls.root
def test_init(self):
self.assertEqual(self.calltip.anchor_widget, self.text)
if __name__ == '__main__':
unittest.main(verbosity=2)
Reported by Pylint.
Doc/includes/email-dir.py
5 issues
Line: 1
Column: 1
#!/usr/bin/env python3
"""Send the contents of a directory as a MIME message."""
import os
import smtplib
# For guessing MIME type based on file name extension
import mimetypes
Reported by Pylint.
Line: 16
Column: 1
from email.policy import SMTP
def main():
parser = ArgumentParser(description="""\
Send the contents of a directory as a MIME message.
Unless the -o option is given, the email is sent by forwarding to your local
SMTP server, which then does the normal delivery process. Your local machine
must be running an SMTP server.
Reported by Pylint.
Line: 62
Column: 34
# use a generic bag-of-bits type.
ctype = 'application/octet-stream'
maintype, subtype = ctype.split('/', 1)
with open(path, 'rb') as fp:
msg.add_attachment(fp.read(),
maintype=maintype,
subtype=subtype,
filename=filename)
# Now send or store the message
Reported by Pylint.
Line: 69
Column: 41
filename=filename)
# Now send or store the message
if args.output:
with open(args.output, 'wb') as fp:
fp.write(msg.as_bytes(policy=SMTP))
else:
with smtplib.SMTP('localhost') as s:
s.send_message(msg)
Reported by Pylint.
Line: 72
Column: 43
with open(args.output, 'wb') as fp:
fp.write(msg.as_bytes(policy=SMTP))
else:
with smtplib.SMTP('localhost') as s:
s.send_message(msg)
if __name__ == '__main__':
main()
Reported by Pylint.
Lib/idlelib/hyperparser.py
5 issues
Line: 163
Column: 30
_ID_KEYWORDS = frozenset({"True", "False", "None"})
@classmethod
def _eat_identifier(cls, str, limit, pos):
"""Given a string and pos, return the number of chars in the
identifier which ends at pos, or 0 if there is no such one.
This ignores non-identifier eywords are not identifiers.
"""
Reported by Pylint.
Line: 25
Column: 1
[(chr(x) in _ASCII_ID_FIRST_CHARS) for x in range(128)]
class HyperParser:
def __init__(self, editwin, index):
"To initialize, analyze the surroundings of the given index."
self.editwin = editwin
self.text = text = editwin.text
Reported by Pylint.
Line: 25
Column: 1
[(chr(x) in _ASCII_ID_FIRST_CHARS) for x in range(128)]
class HyperParser:
def __init__(self, editwin, index):
"To initialize, analyze the surroundings of the given index."
self.editwin = editwin
self.text = text = editwin.text
Reported by Pylint.
Line: 54
Column: 13
break
parser.set_lo(bod or 0)
else:
r = text.tag_prevrange("console", index)
if r:
startatindex = r[1]
else:
startatindex = "1.0"
stopatindex = "%d.end" % lno
Reported by Pylint.
Line: 222
Column: 5
# This string includes all chars that may be in a white space
_whitespace_chars = " \t\n\\"
def get_expression(self):
"""Return a string with the Python expression which ends at the
given index, which is empty if there is no real one.
"""
if not self.is_in_code():
raise ValueError("get_expression should only be called "
Reported by Pylint.