The following issues were found

Lib/lib2to3/fixes/fix_xrange.py
18 issues
Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              """Fixer that changes xrange(...) into range(...)."""

# Local imports
from .. import fixer_base
from ..fixer_util import Name, Call, consuming_calls
from .. import patcomp


class FixXrange(fixer_base.BaseFix):

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              
# Local imports
from .. import fixer_base
from ..fixer_util import Name, Call, consuming_calls
from .. import patcomp


class FixXrange(fixer_base.BaseFix):
    BM_compatible = True

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

              # Local imports
from .. import fixer_base
from ..fixer_util import Name, Call, consuming_calls
from .. import patcomp


class FixXrange(fixer_base.BaseFix):
    BM_compatible = True
    PATTERN = """

            

Reported by Pylint.

Attribute 'transformed_xranges' defined outside __init__
Error

Line: 22 Column: 9

              
    def start_tree(self, tree, filename):
        super(FixXrange, self).start_tree(tree, filename)
        self.transformed_xranges = set()

    def finish_tree(self, tree, filename):
        self.transformed_xranges = None

    def transform(self, node, results):

            

Reported by Pylint.

Unused argument 'filename'
Error

Line: 24 Column: 33

                      super(FixXrange, self).start_tree(tree, filename)
        self.transformed_xranges = set()

    def finish_tree(self, tree, filename):
        self.transformed_xranges = None

    def transform(self, node, results):
        name = results["name"]
        if name.value == "xrange":

            

Reported by Pylint.

Unused argument 'tree'
Error

Line: 24 Column: 27

                      super(FixXrange, self).start_tree(tree, filename)
        self.transformed_xranges = set()

    def finish_tree(self, tree, filename):
        self.transformed_xranges = None

    def transform(self, node, results):
        name = results["name"]
        if name.value == "xrange":

            

Reported by Pylint.

Attribute 'transformed_xranges' defined outside __init__
Error

Line: 25 Column: 9

                      self.transformed_xranges = set()

    def finish_tree(self, tree, filename):
        self.transformed_xranges = None

    def transform(self, node, results):
        name = results["name"]
        if name.value == "xrange":
            return self.transform_xrange(node, results)

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              from .. import patcomp


class FixXrange(fixer_base.BaseFix):
    BM_compatible = True
    PATTERN = """
              power<
                 (name='range'|name='xrange') trailer< '(' args=any ')' >
              rest=any* >

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 5

                            rest=any* >
              """

    def start_tree(self, tree, filename):
        super(FixXrange, self).start_tree(tree, filename)
        self.transformed_xranges = set()

    def finish_tree(self, tree, filename):
        self.transformed_xranges = None

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 21 Column: 9

                            """

    def start_tree(self, tree, filename):
        super(FixXrange, self).start_tree(tree, filename)
        self.transformed_xranges = set()

    def finish_tree(self, tree, filename):
        self.transformed_xranges = None


            

Reported by Pylint.

Lib/bisect.py
18 issues
Wildcard import _bisect
Error

Line: 104 Column: 5

              
# Overwrite above definitions with a fast C implementation
try:
    from _bisect import *
except ImportError:
    pass

# Create aliases
bisect = bisect_right

            

Reported by Pylint.

Unused import insort_left from wildcard import
Error

Line: 104 Column: 5

              
# Overwrite above definitions with a fast C implementation
try:
    from _bisect import *
except ImportError:
    pass

# Create aliases
bisect = bisect_right

            

Reported by Pylint.

Argument name "hi" doesn't conform to snake_case naming style
Error

Line: 4 Column: 1

              """Bisection algorithms."""


def insort_right(a, x, lo=0, hi=None, *, key=None):
    """Insert item x in list a, and keep it sorted assuming a is sorted.

    If x is already in a, insert it to the right of the rightmost x.

    Optional args lo (default 0) and hi (default len(a)) bound the

            

Reported by Pylint.

Argument name "a" doesn't conform to snake_case naming style
Error

Line: 4 Column: 1

              """Bisection algorithms."""


def insort_right(a, x, lo=0, hi=None, *, key=None):
    """Insert item x in list a, and keep it sorted assuming a is sorted.

    If x is already in a, insert it to the right of the rightmost x.

    Optional args lo (default 0) and hi (default len(a)) bound the

            

Reported by Pylint.

Argument name "x" doesn't conform to snake_case naming style
Error

Line: 4 Column: 1

              """Bisection algorithms."""


def insort_right(a, x, lo=0, hi=None, *, key=None):
    """Insert item x in list a, and keep it sorted assuming a is sorted.

    If x is already in a, insert it to the right of the rightmost x.

    Optional args lo (default 0) and hi (default len(a)) bound the

            

Reported by Pylint.

Argument name "lo" doesn't conform to snake_case naming style
Error

Line: 4 Column: 1

              """Bisection algorithms."""


def insort_right(a, x, lo=0, hi=None, *, key=None):
    """Insert item x in list a, and keep it sorted assuming a is sorted.

    If x is already in a, insert it to the right of the rightmost x.

    Optional args lo (default 0) and hi (default len(a)) bound the

            

Reported by Pylint.

Argument name "a" doesn't conform to snake_case naming style
Error

Line: 19 Column: 1

                  a.insert(lo, x)


def bisect_right(a, x, lo=0, hi=None, *, key=None):
    """Return the index where to insert item x in list a, assuming a is sorted.

    The return value i is such that all e in a[:i] have e <= x, and all e in
    a[i:] have e > x.  So if x already appears in the list, a.insert(i, x) will
    insert just after the rightmost x already there.

            

Reported by Pylint.

Argument name "hi" doesn't conform to snake_case naming style
Error

Line: 19 Column: 1

                  a.insert(lo, x)


def bisect_right(a, x, lo=0, hi=None, *, key=None):
    """Return the index where to insert item x in list a, assuming a is sorted.

    The return value i is such that all e in a[:i] have e <= x, and all e in
    a[i:] have e > x.  So if x already appears in the list, a.insert(i, x) will
    insert just after the rightmost x already there.

            

Reported by Pylint.

Argument name "lo" doesn't conform to snake_case naming style
Error

Line: 19 Column: 1

                  a.insert(lo, x)


def bisect_right(a, x, lo=0, hi=None, *, key=None):
    """Return the index where to insert item x in list a, assuming a is sorted.

    The return value i is such that all e in a[:i] have e <= x, and all e in
    a[i:] have e > x.  So if x already appears in the list, a.insert(i, x) will
    insert just after the rightmost x already there.

            

Reported by Pylint.

Argument name "x" doesn't conform to snake_case naming style
Error

Line: 19 Column: 1

                  a.insert(lo, x)


def bisect_right(a, x, lo=0, hi=None, *, key=None):
    """Return the index where to insert item x in list a, assuming a is sorted.

    The return value i is such that all e in a[:i] have e <= x, and all e in
    a[i:] have e > x.  So if x already appears in the list, a.insert(i, x) will
    insert just after the rightmost x already there.

            

Reported by Pylint.

Lib/code.py
18 issues
Cannot import 'traceback' due to syntax error 'invalid syntax (<unknown>, line 576)'
Error

Line: 9 Column: 1

              

import sys
import traceback
from codeop import CommandCompiler, compile_command

__all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact",
           "compile_command"]


            

Reported by Pylint.

Redefining built-in 'locals'
Error

Line: 24 Column: 24

              
    """

    def __init__(self, locals=None):
        """Constructor.

        The optional 'locals' argument specifies the dictionary in
        which code will be executed; it defaults to a newly created
        dictionary with key "__name__" set to "__console__" and key

            

Reported by Pylint.

Use of exec detected.
Security

Line: 90
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html

              
        """
        try:
            exec(code, self.locals)
        except SystemExit:
            raise
        except:
            self.showtraceback()


            

Reported by Bandit.

Use of exec
Error

Line: 90 Column: 13

              
        """
        try:
            exec(code, self.locals)
        except SystemExit:
            raise
        except:
            self.showtraceback()


            

Reported by Pylint.

No exception type(s) specified
Error

Line: 93 Column: 9

                          exec(code, self.locals)
        except SystemExit:
            raise
        except:
            self.showtraceback()

    def showsyntaxerror(self, filename=None):
        """Display the syntax error that just occurred.


            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 108 Column: 9

                      The output is written by self.write(), below.

        """
        type, value, tb = sys.exc_info()
        sys.last_type = type
        sys.last_value = value
        sys.last_traceback = tb
        if filename and type is SyntaxError:
            # Work hard to stuff the correct filename in the exception

            

Reported by Pylint.

Redefining built-in 'locals'
Error

Line: 170 Column: 24

              
    """

    def __init__(self, locals=None, filename="<console>"):
        """Constructor.

        The optional locals argument will be passed to the
        InteractiveInterpreter base class.


            

Reported by Pylint.

Redefining name 'banner' from outer scope (line 312)
Error

Line: 188 Column: 24

                      """Reset the input buffer."""
        self.buffer = []

    def interact(self, banner=None, exitmsg=None):
        """Closely emulate the interactive Python console.

        The optional banner argument specifies the banner to print
        before the first interaction; by default it prints a banner
        similar to the one printed by the real Python interpreter,

            

Reported by Pylint.

Redefining name 'banner' from outer scope (line 312)
Error

Line: 278 Column: 14

              


def interact(banner=None, readfunc=None, local=None, exitmsg=None):
    """Closely emulate the interactive Python interpreter.

    This is a backwards compatible interface to the InteractiveConsole
    class.  When readfunc is not specified, it attempts to import the
    readline module to enable GNU readline if it is available.

            

Reported by Pylint.

Unused import readline
Error

Line: 298 Column: 13

                      console.raw_input = readfunc
    else:
        try:
            import readline
        except ImportError:
            pass
    console.interact(banner, exitmsg)



            

Reported by Pylint.

Lib/encodings/base64_codec.py
18 issues
Redefining built-in 'input'
Error

Line: 13 Column: 19

              
### Codec APIs

def base64_encode(input, errors='strict'):
    assert errors == 'strict'
    return (base64.encodebytes(input), len(input))

def base64_decode(input, errors='strict'):
    assert errors == 'strict'

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 17 Column: 19

                  assert errors == 'strict'
    return (base64.encodebytes(input), len(input))

def base64_decode(input, errors='strict'):
    assert errors == 'strict'
    return (base64.decodebytes(input), len(input))

class Codec(codecs.Codec):
    def encode(self, input, errors='strict'):

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 22 Column: 22

                  return (base64.decodebytes(input), len(input))

class Codec(codecs.Codec):
    def encode(self, input, errors='strict'):
        return base64_encode(input, errors)
    def decode(self, input, errors='strict'):
        return base64_decode(input, errors)

class IncrementalEncoder(codecs.IncrementalEncoder):

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 24 Column: 22

              class Codec(codecs.Codec):
    def encode(self, input, errors='strict'):
        return base64_encode(input, errors)
    def decode(self, input, errors='strict'):
        return base64_decode(input, errors)

class IncrementalEncoder(codecs.IncrementalEncoder):
    def encode(self, input, final=False):
        assert self.errors == 'strict'

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 28 Column: 22

                      return base64_decode(input, errors)

class IncrementalEncoder(codecs.IncrementalEncoder):
    def encode(self, input, final=False):
        assert self.errors == 'strict'
        return base64.encodebytes(input)

class IncrementalDecoder(codecs.IncrementalDecoder):
    def decode(self, input, final=False):

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 33 Column: 22

                      return base64.encodebytes(input)

class IncrementalDecoder(codecs.IncrementalDecoder):
    def decode(self, input, final=False):
        assert self.errors == 'strict'
        return base64.decodebytes(input)

class StreamWriter(Codec, codecs.StreamWriter):
    charbuffertype = bytes

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              
### Codec APIs

def base64_encode(input, errors='strict'):
    assert errors == 'strict'
    return (base64.encodebytes(input), len(input))

def base64_decode(input, errors='strict'):
    assert errors == 'strict'

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 14
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              ### Codec APIs

def base64_encode(input, errors='strict'):
    assert errors == 'strict'
    return (base64.encodebytes(input), len(input))

def base64_decode(input, errors='strict'):
    assert errors == 'strict'
    return (base64.decodebytes(input), len(input))

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 17 Column: 1

                  assert errors == 'strict'
    return (base64.encodebytes(input), len(input))

def base64_decode(input, errors='strict'):
    assert errors == 'strict'
    return (base64.decodebytes(input), len(input))

class Codec(codecs.Codec):
    def encode(self, input, errors='strict'):

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 18
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  return (base64.encodebytes(input), len(input))

def base64_decode(input, errors='strict'):
    assert errors == 'strict'
    return (base64.decodebytes(input), len(input))

class Codec(codecs.Codec):
    def encode(self, input, errors='strict'):
        return base64_encode(input, errors)

            

Reported by Bandit.

Lib/idlelib/grep.py
18 issues
Access to a protected member _root of a client class
Error

Line: 34 Column: 12

                      io: iomenu.IOBinding instance with default path to search.
        flist: filelist.FileList instance for OutputWindow parent.
    """
    root = text._root()
    engine = searchengine.get(root)
    if not hasattr(engine, "_grepdialog"):
        engine._grepdialog = GrepDialog(root, engine, flist)
    dialog = engine._grepdialog
    searchphrase = text.get("sel.first", "sel.last")

            

Reported by Pylint.

Access to a protected member _grepdialog of a client class
Error

Line: 37 Column: 9

                  root = text._root()
    engine = searchengine.get(root)
    if not hasattr(engine, "_grepdialog"):
        engine._grepdialog = GrepDialog(root, engine, flist)
    dialog = engine._grepdialog
    searchphrase = text.get("sel.first", "sel.last")
    dialog.open(text, searchphrase, io)



            

Reported by Pylint.

Access to a protected member _grepdialog of a client class
Error

Line: 38 Column: 14

                  engine = searchengine.get(root)
    if not hasattr(engine, "_grepdialog"):
        engine._grepdialog = GrepDialog(root, engine, flist)
    dialog = engine._grepdialog
    searchphrase = text.get("sel.first", "sel.last")
    dialog.open(text, searchphrase, io)


def walk_error(msg):

            

Reported by Pylint.

Parameters differ from overridden 'open' method
Error

Line: 90 Column: 5

                      self.globvar = StringVar(root)
        self.recvar = BooleanVar(root)

    def open(self, text, searchphrase, io=None):
        """Make dialog visible on top of others and ready to use.

        Extend the SearchDialogBase open() to set the initial value
        for globvar.


            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 106 Column: 9

                          path = io.filename or ""
        else:
            path = ""
        dir, base = os.path.split(path)
        head, tail = os.path.splitext(base)
        if not tail:
            tail = ".py"
        self.globvar.set(os.path.join(dir, "*" + tail))


            

Reported by Pylint.

Unused variable 'head'
Error

Line: 107 Column: 9

                      else:
            path = ""
        dir, base = os.path.split(path)
        head, tail = os.path.splitext(base)
        if not tail:
            tail = ".py"
        self.globvar.set(os.path.join(dir, "*" + tail))

    def create_entries(self):

            

Reported by Pylint.

Attribute 'globent' defined outside __init__
Error

Line: 115 Column: 9

                  def create_entries(self):
        "Create base entry widgets and add widget for search path."
        SearchDialogBase.create_entries(self)
        self.globent = self.make_entry("In files:", self.globvar)[0]

    def create_other_buttons(self):
        "Add check button to recurse down subdirectories."
        btn = Checkbutton(
                self.make_frame()[0], variable=self.recvar,

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 129 Column: 31

                      SearchDialogBase.create_command_buttons(self)
        self.make_button("Search Files", self.default_command, isdef=True)

    def default_command(self, event=None):
        """Grep for search pattern in file path. The default command is bound
        to <Return>.

        If entry values are populated, set OutputWindow as stdout
        and perform search.  The search dialog is closed automatically

            

Reported by Pylint.

Argument name "io" doesn't conform to snake_case naming style
Error

Line: 20 Column: 1

              # EditorWindow -> GrepDialog -> OutputWindow -> EditorWindow


def grep(text, io=None, flist=None):
    """Open the Find in Files dialog.

    Module-level function to access the singleton GrepDialog
    instance and open the dialog.  If text is selected, it is
    used as the search phrase; otherwise, the previous entry

            

Reported by Pylint.

Import outside toplevel (idlelib.outwin.OutputWindow)
Error

Line: 144 Column: 9

                      if not path:
            self.top.bell()
            return
        from idlelib.outwin import OutputWindow  # leave here!
        save = sys.stdout
        try:
            sys.stdout = OutputWindow(self.flist)
            self.grep_it(prog, path)
        finally:

            

Reported by Pylint.

Lib/lib2to3/pgen2/driver.py
18 issues
Attempted relative import beyond top-level package
Error

Line: 26 Column: 1

              import sys

# Pgen imports
from . import grammar, parse, token, tokenize, pgen


class Driver(object):

    def __init__(self, grammar, convert=None, logger=None):

            

Reported by Pylint.

Redefining name 'grammar' from outer scope (line 26)
Error

Line: 31 Column: 24

              
class Driver(object):

    def __init__(self, grammar, convert=None, logger=None):
        self.grammar = grammar
        if logger is None:
            logger = logging.getLogger()
        self.logger = logger
        self.convert = convert

            

Reported by Pylint.

XXX Move the prefix computation into a wrapper around tokenize.
Error

Line: 40 Column: 3

              
    def parse_tokens(self, tokens, debug=False):
        """Parse a series of tokens and return the syntax tree."""
        # XXX Move the prefix computation into a wrapper around tokenize.
        p = parse.Parser(self.grammar, self.convert)
        p.setup()
        lineno = 1
        column = 0
        type = value = start = end = line_text = None

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 45 Column: 9

                      p.setup()
        lineno = 1
        column = 0
        type = value = start = end = line_text = None
        prefix = ""
        for quintuple in tokens:
            type, value, start, end, line_text = quintuple
            if start != (lineno, column):
                assert (lineno, column) <= start, ((lineno, column), start)

            

Reported by Pylint.

Class 'Driver' inherits from object, can be safely removed from bases in python3
Error

Line: 29 Column: 1

              from . import grammar, parse, token, tokenize, pgen


class Driver(object):

    def __init__(self, grammar, convert=None, logger=None):
        self.grammar = grammar
        if logger is None:
            logger = logging.getLogger()

            

Reported by Pylint.

Missing class docstring
Error

Line: 29 Column: 1

              from . import grammar, parse, token, tokenize, pgen


class Driver(object):

    def __init__(self, grammar, convert=None, logger=None):
        self.grammar = grammar
        if logger is None:
            logger = logging.getLogger()

            

Reported by Pylint.

Variable name "p" doesn't conform to snake_case naming style
Error

Line: 41 Column: 9

                  def parse_tokens(self, tokens, debug=False):
        """Parse a series of tokens and return the syntax tree."""
        # XXX Move the prefix computation into a wrapper around tokenize.
        p = parse.Parser(self.grammar, self.convert)
        p.setup()
        lineno = 1
        column = 0
        type = value = start = end = line_text = None
        prefix = ""

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 50
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      for quintuple in tokens:
            type, value, start, end, line_text = quintuple
            if start != (lineno, column):
                assert (lineno, column) <= start, ((lineno, column), start)
                s_lineno, s_column = start
                if lineno < s_lineno:
                    prefix += "\n" * (s_lineno - lineno)
                    lineno = s_lineno
                    column = 0

            

Reported by Bandit.

Argument name "gt" doesn't conform to snake_case naming style
Error

Line: 106 Column: 1

                      return self.parse_tokens(tokens, debug)


def _generate_pickle_name(gt):
    head, tail = os.path.splitext(gt)
    if tail == ".txt":
        tail = ""
    return head + tail + ".".join(map(str, sys.version_info)) + ".pickle"


            

Reported by Pylint.

Argument name "gt" doesn't conform to snake_case naming style
Error

Line: 113 Column: 1

                  return head + tail + ".".join(map(str, sys.version_info)) + ".pickle"


def load_grammar(gt="Grammar.txt", gp=None,
                 save=True, force=False, logger=None):
    """Load the grammar (maybe from a pickle)."""
    if logger is None:
        logger = logging.getLogger()
    gp = _generate_pickle_name(gt) if gp is None else gp

            

Reported by Pylint.

Lib/distutils/text_file.py
18 issues
Instance of 'TextFile' has no 'errors' member; maybe 'error'?
Error

Line: 115 Column: 56

                      """Open a new file named 'filename'.  This overrides both the
           'filename' and 'file' arguments to the constructor."""
        self.filename = filename
        self.file = io.open(self.filename, 'r', errors=self.errors)
        self.current_line = 0

    def close(self):
        """Close the current file and forget everything we know about it
           (filename, current line number)."""

            

Reported by Pylint.

Instance of 'TextFile' has no 'strip_comments' member
Error

Line: 179 Column: 16

                          if line == '':
                line = None

            if self.strip_comments and line:

                # Look for the first "#" in the line.  If none, never
                # mind.  If we find one and it's the first character, or
                # is not preceded by "\", then it starts a comment --
                # strip the comment, strip whitespace before it, and

            

Reported by Pylint.

Instance of 'TextFile' has no 'join_lines' member
Error

Line: 218 Column: 16

                                  line = line.replace("\\#", "#")

            # did previous line end with a backslash? then accumulate
            if self.join_lines and buildup_line:
                # oops: end of file
                if line is None:
                    self.warn("continuation line immediately precedes "
                              "end-of-file")
                    return buildup_line

            

Reported by Pylint.

Instance of 'TextFile' has no 'collapse_join' member
Error

Line: 225 Column: 20

                                            "end-of-file")
                    return buildup_line

                if self.collapse_join:
                    line = line.lstrip()
                line = buildup_line + line

                # careful: pay attention to line number when incrementing it
                if isinstance(self.current_line, list):

            

Reported by Pylint.

Instance of 'TextFile' has no 'rstrip_ws' member
Error

Line: 248 Column: 35

              
            # strip whitespace however the client wants (leading and
            # trailing, or one or the other, or neither)
            if self.lstrip_ws and self.rstrip_ws:
                line = line.strip()
            elif self.lstrip_ws:
                line = line.lstrip()
            elif self.rstrip_ws:
                line = line.rstrip()

            

Reported by Pylint.

Instance of 'TextFile' has no 'lstrip_ws' member
Error

Line: 248 Column: 16

              
            # strip whitespace however the client wants (leading and
            # trailing, or one or the other, or neither)
            if self.lstrip_ws and self.rstrip_ws:
                line = line.strip()
            elif self.lstrip_ws:
                line = line.lstrip()
            elif self.rstrip_ws:
                line = line.rstrip()

            

Reported by Pylint.

Instance of 'TextFile' has no 'lstrip_ws' member
Error

Line: 250 Column: 18

                          # trailing, or one or the other, or neither)
            if self.lstrip_ws and self.rstrip_ws:
                line = line.strip()
            elif self.lstrip_ws:
                line = line.lstrip()
            elif self.rstrip_ws:
                line = line.rstrip()

            # blank line (whether we rstrip'ed or not)? skip to next line

            

Reported by Pylint.

Instance of 'TextFile' has no 'rstrip_ws' member
Error

Line: 252 Column: 18

                              line = line.strip()
            elif self.lstrip_ws:
                line = line.lstrip()
            elif self.rstrip_ws:
                line = line.rstrip()

            # blank line (whether we rstrip'ed or not)? skip to next line
            # if appropriate
            if (line == '' or line == '\n') and self.skip_blanks:

            

Reported by Pylint.

Instance of 'TextFile' has no 'skip_blanks' member
Error

Line: 257 Column: 49

              
            # blank line (whether we rstrip'ed or not)? skip to next line
            # if appropriate
            if (line == '' or line == '\n') and self.skip_blanks:
                continue

            if self.join_lines:
                if line[-1] == '\\':
                    buildup_line = line[:-1]

            

Reported by Pylint.

Instance of 'TextFile' has no 'join_lines' member
Error

Line: 260 Column: 16

                          if (line == '' or line == '\n') and self.skip_blanks:
                continue

            if self.join_lines:
                if line[-1] == '\\':
                    buildup_line = line[:-1]
                    continue

                if line[-2:] == '\\\n':

            

Reported by Pylint.

Lib/distutils/command/upload.py
18 issues
Attribute 'username' defined outside __init__
Error

Line: 58 Column: 13

                          )
        config = self._read_pypirc()
        if config != {}:
            self.username = config['username']
            self.password = config['password']
            self.repository = config['repository']
            self.realm = config['realm']

        # getting the password from the distribution

            

Reported by Pylint.

Attribute 'password' defined outside __init__
Error

Line: 59 Column: 13

                      config = self._read_pypirc()
        if config != {}:
            self.username = config['username']
            self.password = config['password']
            self.repository = config['repository']
            self.realm = config['realm']

        # getting the password from the distribution
        # if previously set by the register command

            

Reported by Pylint.

Attribute 'password' defined outside __init__
Error

Line: 66 Column: 13

                      # getting the password from the distribution
        # if previously set by the register command
        if not self.password and self.distribution.password:
            self.password = self.distribution.password

    def run(self):
        if not self.distribution.dist_files:
            msg = ("Must create and upload files in one command "
                   "(e.g. setup.py sdist upload)")

            

Reported by Pylint.

Unused variable 'url'
Error

Line: 78 Column: 25

              
    def upload_file(self, command, pyversion, filename):
        # Makes sure the repository URL is compliant
        schema, netloc, url, params, query, fragments = \
            urlparse(self.repository)
        if params or query or fragments:
            raise AssertionError("Incompatible url %s" % self.repository)

        if schema not in ('http', 'https'):

            

Reported by Pylint.

Unused variable 'netloc'
Error

Line: 78 Column: 17

              
    def upload_file(self, command, pyversion, filename):
        # Makes sure the repository URL is compliant
        schema, netloc, url, params, query, fragments = \
            urlparse(self.repository)
        if params or query or fragments:
            raise AssertionError("Incompatible url %s" % self.repository)

        if schema not in ('http', 'https'):

            

Reported by Pylint.

Redefining name 'value' from outer scope (line 163)
Error

Line: 168 Column: 13

                          # handle multiple entries for the same name
            if not isinstance(value, list):
                value = [value]
            for value in value:
                if type(value) is tuple:
                    title += '; filename="%s"' % value[0]
                    value = value[1]
                else:
                    value = str(value).encode('utf-8')

            

Reported by Pylint.

Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.
Security blacklist

Line: 195
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b310-urllib-urlopen

                                        headers=headers)
        # send the data
        try:
            result = urlopen(request)
            status = result.getcode()
            reason = result.msg
        except HTTPError as e:
            status = e.code
            reason = e.msg

            

Reported by Bandit.

Class name "upload" doesn't conform to PascalCase naming style
Error

Line: 30 Column: 1

              }


class upload(PyPIRCCommand):

    description = "upload binary package to PyPI"

    user_options = PyPIRCCommand.user_options + [
        ('sign', 's',

            

Reported by Pylint.

Missing class docstring
Error

Line: 30 Column: 1

              }


class upload(PyPIRCCommand):

    description = "upload binary package to PyPI"

    user_options = PyPIRCCommand.user_options + [
        ('sign', 's',

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 76 Column: 5

                      for command, pyversion, filename in self.distribution.dist_files:
            self.upload_file(command, pyversion, filename)

    def upload_file(self, command, pyversion, filename):
        # Makes sure the repository URL is compliant
        schema, netloc, url, params, query, fragments = \
            urlparse(self.repository)
        if params or query or fragments:
            raise AssertionError("Incompatible url %s" % self.repository)

            

Reported by Pylint.

Lib/distutils/tests/test_config.py
18 issues
Access to a protected member _read_pypirc of a client class
Error

Line: 93 Column: 18

                      # new format
        self.write_file(self.rc, PYPIRC)
        cmd = self._cmd(self.dist)
        config = cmd._read_pypirc()

        config = list(sorted(config.items()))
        waited = [('password', 'secret'), ('realm', 'pypi'),
                  ('repository', 'https://upload.pypi.org/legacy/'),
                  ('server', 'server1'), ('username', 'me')]

            

Reported by Pylint.

Access to a protected member _read_pypirc of a client class
Error

Line: 103 Column: 18

              
        # old format
        self.write_file(self.rc, PYPIRC_OLD)
        config = cmd._read_pypirc()
        config = list(sorted(config.items()))
        waited = [('password', 'secret'), ('realm', 'pypi'),
                  ('repository', 'https://upload.pypi.org/legacy/'),
                  ('server', 'server-login'), ('username', 'tarek')]
        self.assertEqual(config, waited)

            

Reported by Pylint.

Access to a protected member _get_rc_file of a client class
Error

Line: 112 Column: 14

              
    def test_server_empty_registration(self):
        cmd = self._cmd(self.dist)
        rc = cmd._get_rc_file()
        self.assertFalse(os.path.exists(rc))
        cmd._store_pypirc('tarek', 'xxx')
        self.assertTrue(os.path.exists(rc))
        f = open(rc)
        try:

            

Reported by Pylint.

Access to a protected member _store_pypirc of a client class
Error

Line: 114 Column: 9

                      cmd = self._cmd(self.dist)
        rc = cmd._get_rc_file()
        self.assertFalse(os.path.exists(rc))
        cmd._store_pypirc('tarek', 'xxx')
        self.assertTrue(os.path.exists(rc))
        f = open(rc)
        try:
            content = f.read()
            self.assertEqual(content, WANTED)

            

Reported by Pylint.

Access to a protected member _read_pypirc of a client class
Error

Line: 128 Column: 18

                      self.write_file(self.rc, PYPIRC)
        cmd = self._cmd(self.dist)
        cmd.repository = 'server3'
        config = cmd._read_pypirc()

        config = list(sorted(config.items()))
        waited = [('password', 'yh^%#rest-of-my-password'), ('realm', 'pypi'),
                  ('repository', 'https://upload.pypi.org/legacy/'),
                  ('server', 'server3'), ('username', 'cbiggles')]

            

Reported by Pylint.

Missing class docstring
Error

Line: 53 Column: 1

              """


class BasePyPIRCCommandTestCase(support.TempdirManager,
                            support.LoggingSilencer,
                            support.EnvironGuard,
                            unittest.TestCase):

    def setUp(self):

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 60 Column: 9

              
    def setUp(self):
        """Patches the environment."""
        super(BasePyPIRCCommandTestCase, self).setUp()
        self.tmp_dir = self.mkdtemp()
        os.environ['HOME'] = self.tmp_dir
        os.environ['USERPROFILE'] = self.tmp_dir
        self.rc = os.path.join(self.tmp_dir, '.pypirc')
        self.dist = Distribution()

            

Reported by Pylint.

Attribute name "rc" doesn't conform to snake_case naming style
Error

Line: 64 Column: 9

                      self.tmp_dir = self.mkdtemp()
        os.environ['HOME'] = self.tmp_dir
        os.environ['USERPROFILE'] = self.tmp_dir
        self.rc = os.path.join(self.tmp_dir, '.pypirc')
        self.dist = Distribution()

        class command(PyPIRCCommand):
            def __init__(self, dist):
                PyPIRCCommand.__init__(self, dist)

            

Reported by Pylint.

Class name "command" doesn't conform to PascalCase naming style
Error

Line: 67 Column: 9

                      self.rc = os.path.join(self.tmp_dir, '.pypirc')
        self.dist = Distribution()

        class command(PyPIRCCommand):
            def __init__(self, dist):
                PyPIRCCommand.__init__(self, dist)
            def initialize_options(self):
                pass
            finalize_options = initialize_options

            

Reported by Pylint.

Missing class docstring
Error

Line: 67 Column: 9

                      self.rc = os.path.join(self.tmp_dir, '.pypirc')
        self.dist = Distribution()

        class command(PyPIRCCommand):
            def __init__(self, dist):
                PyPIRCCommand.__init__(self, dist)
            def initialize_options(self):
                pass
            finalize_options = initialize_options

            

Reported by Pylint.

Lib/distutils/tests/test_file_util.py
18 issues
Missing class docstring
Error

Line: 15 Column: 1

              from test.support.os_helper import unlink


class FileUtilTestCase(support.TempdirManager, unittest.TestCase):

    def _log(self, msg, *args):
        if len(args) > 0:
            self._logs.append(msg % args)
        else:

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 24 Column: 9

                          self._logs.append(msg)

    def setUp(self):
        super(FileUtilTestCase, self).setUp()
        self._logs = []
        self.old_log = log.info
        log.info = self._log
        tmp_dir = self.mkdtemp()
        self.source = os.path.join(tmp_dir, 'f1')

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 35 Column: 9

              
    def tearDown(self):
        log.info = self.old_log
        super(FileUtilTestCase, self).tearDown()

    def test_move_file_verbosity(self):
        f = open(self.source, 'w')
        try:
            f.write('some content')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 37 Column: 5

                      log.info = self.old_log
        super(FileUtilTestCase, self).tearDown()

    def test_move_file_verbosity(self):
        f = open(self.source, 'w')
        try:
            f.write('some content')
        finally:
            f.close()

            

Reported by Pylint.

Variable name "f" doesn't conform to snake_case naming style
Error

Line: 38 Column: 9

                      super(FileUtilTestCase, self).tearDown()

    def test_move_file_verbosity(self):
        f = open(self.source, 'w')
        try:
            f.write('some content')
        finally:
            f.close()


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 65 Column: 5

                      wanted = ['moving %s -> %s' % (self.source, self.target_dir)]
        self.assertEqual(self._logs, wanted)

    def test_move_file_exception_unpacking_rename(self):
        # see issue 22182
        with patch("os.rename", side_effect=OSError("wrong", 1)), \
             self.assertRaises(DistutilsFileError):
            with open(self.source, 'w') as fobj:
                fobj.write('spam eggs')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 73 Column: 5

                              fobj.write('spam eggs')
            move_file(self.source, self.target, verbose=0)

    def test_move_file_exception_unpacking_unlink(self):
        # see issue 22182
        with patch("os.rename", side_effect=OSError(errno.EXDEV, "wrong")), \
             patch("os.unlink", side_effect=OSError("wrong", 1)), \
             self.assertRaises(DistutilsFileError):
            with open(self.source, 'w') as fobj:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 82 Column: 5

                              fobj.write('spam eggs')
            move_file(self.source, self.target, verbose=0)

    def test_copy_file_hard_link(self):
        with open(self.source, 'w') as f:
            f.write('some content')
        # Check first that copy_file() will not fall back on copying the file
        # instead of creating the hard link.
        try:

            

Reported by Pylint.

Variable name "f" doesn't conform to snake_case naming style
Error

Line: 83 Column: 40

                          move_file(self.source, self.target, verbose=0)

    def test_copy_file_hard_link(self):
        with open(self.source, 'w') as f:
            f.write('some content')
        # Check first that copy_file() will not fall back on copying the file
        # instead of creating the hard link.
        try:
            os.link(self.source, self.target)

            

Reported by Pylint.

Variable name "e" doesn't conform to snake_case naming style
Error

Line: 89 Column: 9

                      # instead of creating the hard link.
        try:
            os.link(self.source, self.target)
        except OSError as e:
            self.skipTest('os.link: %s' % e)
        else:
            unlink(self.target)
        st = os.stat(self.source)
        copy_file(self.source, self.target, link='hard')

            

Reported by Pylint.