def is_message_enabled(self, msg_descr, line=None, confidence=None):

if self.config.confidence and confidence:<EOL><INDENT>if confidence.name not in self.config.confidence:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>try:<EOL><INDENT>message_definitions = self.msgs_store.get_message_definitions(msg_descr)<EOL>msgids = [md.msgid for md in message_definitions]<EOL><DEDENT>except UnknownMessageError:<EOL><INDENT>msgids = [msg_descr]<EOL><DEDENT>for msgid in msgids:<EOL><INDENT>if self.is_one_message_enabled(msgid, line):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>return False<EOL>

return true if the message associated to the given message id is
        enabled

        msgid may be either a numeric or symbolic message id.


message_definitions = self.msgs_store.get_message_definitions(msg_descr)<EOL>for message_definition in message_definitions:<EOL><INDENT>self.add_one_message(<EOL>message_definition, line, node, args, confidence, col_offset<EOL>)<EOL><DEDENT>

Adds a message given by ID or name.

        If provided, the message string is expanded using args.

        AST checkers must provide the node argument (but may optionally
        provide line if the line number is different), raw and token checkers
        must provide the line argument.


if not stream:<EOL><INDENT>stream = sys.stdout<EOL><DEDENT>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>by_checker = {}<EOL>for checker in self.get_checkers():<EOL><INDENT>if checker.name == "<STR_LIT>":<EOL><INDENT>if checker.options:<EOL><INDENT>for section, options in checker.options_by_section():<EOL><INDENT>if section is None:<EOL><INDENT>title = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>title = "<STR_LIT>" % section.capitalize()<EOL><DEDENT>print(title, file=stream)<EOL>print("<STR_LIT>" * len(title), file=stream)<EOL>_rest_format_section(stream, None, options)<EOL>print("<STR_LIT>", file=stream)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>name = checker.name<EOL>try:<EOL><INDENT>by_checker[name]["<STR_LIT>"] += checker.options_and_values()<EOL>by_checker[name]["<STR_LIT>"].update(checker.msgs)<EOL>by_checker[name]["<STR_LIT>"] += checker.reports<EOL><DEDENT>except KeyError:<EOL><INDENT>by_checker[name] = {<EOL>"<STR_LIT>": list(checker.options_and_values()),<EOL>"<STR_LIT>": dict(checker.msgs),<EOL>"<STR_LIT>": list(checker.reports),<EOL>}<EOL><DEDENT><DEDENT><DEDENT>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>for checker, info in sorted(by_checker.items()):<EOL><INDENT>self._print_checker_doc(checker, info, stream=stream)<EOL><DEDENT>

output a full documentation in ReST format


@staticmethod<EOL><INDENT>def _print_checker_doc(checker_name, info, stream=None):<DEDENT>

if not stream:<EOL><INDENT>stream = sys.stdout<EOL><DEDENT>doc = info.get("<STR_LIT>")<EOL>module = info.get("<STR_LIT>")<EOL>msgs = info.get("<STR_LIT>")<EOL>options = info.get("<STR_LIT>")<EOL>reports = info.get("<STR_LIT>")<EOL>checker_title = "<STR_LIT>" % (checker_name.replace("<STR_LIT:_>", "<STR_LIT:U+0020>").title())<EOL>if module:<EOL><INDENT>print("<STR_LIT>" % module, file=stream)<EOL><DEDENT>print(checker_title, file=stream)<EOL>print("<STR_LIT>" * len(checker_title), file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>if module:<EOL><INDENT>print("<STR_LIT>" % module, file=stream)<EOL><DEDENT>print("<STR_LIT>" % checker_name, file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL>if doc:<EOL><INDENT>title = "<STR_LIT>".format(checker_title)<EOL>print(title, file=stream)<EOL>print("<STR_LIT>" * len(title), file=stream)<EOL>print(cleandoc(doc), file=stream)<EOL>print("<STR_LIT>", file=stream)<EOL><DEDENT>if options:<EOL><INDENT>title = "<STR_LIT>".format(checker_title)<EOL>print(title, file=stream)<EOL>print("<STR_LIT>" * len(title), file=stream)<EOL>_rest_format_section(stream, None, options)<EOL>print("<STR_LIT>", file=stream)<EOL><DEDENT>if msgs:<EOL><INDENT>title = "<STR_LIT>".format(checker_title)<EOL>print(title, file=stream)<EOL>print("<STR_LIT>" * len(title), file=stream)<EOL>for msgid, msg in sorted(<EOL>msgs.items(), key=lambda kv: (_MSG_ORDER.index(kv[<NUM_LIT:0>][<NUM_LIT:0>]), kv[<NUM_LIT:1>])<EOL>):<EOL><INDENT>msg = build_message_definition(checker_name, msgid, msg)<EOL>print(msg.format_help(checkerref=False), file=stream)<EOL><DEDENT>print("<STR_LIT>", file=stream)<EOL><DEDENT>if reports:<EOL><INDENT>title = "<STR_LIT>".format(checker_title)<EOL>print(title, file=stream)<EOL>print("<STR_LIT>" * len(title), file=stream)<EOL>for report in reports:<EOL><INDENT>print("<STR_LIT>" % report[:<NUM_LIT:2>], file=stream)<EOL><DEDENT>print("<STR_LIT>", file=stream)<EOL><DEDENT>print("<STR_LIT>", file=stream)<EOL>

Helper method for print_full_documentation.

        Also used by doc/exts/pylint_extensions.py.


return self._messages_definitions.values()<EOL>


def add_renamed_message(self, old_id, old_symbol, new_symbol):

message_definition = self.get_message_definitions(new_symbol)[<NUM_LIT:0>]<EOL>message_definition.old_names.append((old_id, old_symbol))<EOL>self._register_alternative_name(message_definition, old_id, old_symbol)<EOL>

Register the old ID and symbol for a warning that was renamed.

        This allows users to keep using the old ID/symbol in suppressions.


checker.check_consistency()<EOL>for message in checker.messages:<EOL><INDENT>self.register_message(message)<EOL><DEDENT>

Register all messages from a checker.

        :param BaseChecker checker:


self._check_id_and_symbol_consistency(message.msgid, message.symbol)<EOL>self._check_symbol(message.msgid, message.symbol)<EOL>self._check_msgid(message.msgid, message.symbol)<EOL>for old_name in message.old_names:<EOL><INDENT>self._check_symbol(message.msgid, old_name[<NUM_LIT:1>])<EOL><DEDENT>self._messages_definitions[message.symbol] = message<EOL>self._register_alternative_name(message, message.msgid, message.symbol)<EOL>for old_id, old_symbol in message.old_names:<EOL><INDENT>self._register_alternative_name(message, old_id, old_symbol)<EOL><DEDENT>self._msgs_by_category[message.msgid[<NUM_LIT:0>]].append(message.msgid)<EOL>

Register a MessageDefinition with consistency in mind.

        :param MessageDefinition message: The message definition being added.


def _register_alternative_name(self, msg, msgid, symbol):

self._check_id_and_symbol_consistency(msgid, symbol)<EOL>self._alternative_names[msgid] = msg<EOL>self._alternative_names[symbol] = msg<EOL>


other_message = self._messages_definitions.get(symbol)<EOL>if other_message:<EOL><INDENT>self._raise_duplicate_msg_id(symbol, msgid, other_message.msgid)<EOL><DEDENT>else:<EOL><INDENT>alternative_msgid = None<EOL><DEDENT>alternative_message = self._alternative_names.get(symbol)<EOL>if alternative_message:<EOL><INDENT>if alternative_message.symbol == symbol:<EOL><INDENT>alternative_msgid = alternative_message.msgid<EOL><DEDENT>else:<EOL><INDENT>for old_msgid, old_symbol in alternative_message.old_names:<EOL><INDENT>if old_symbol == symbol:<EOL><INDENT>alternative_msgid = old_msgid<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if msgid != alternative_msgid:<EOL><INDENT>self._raise_duplicate_msg_id(symbol, msgid, alternative_msgid)<EOL><DEDENT><DEDENT>

Check that a symbol is not already used.


@staticmethod<EOL><INDENT>def _raise_duplicate_symbol(msgid, symbol, other_symbol):<DEDENT>

symbols = [symbol, other_symbol]<EOL>symbols.sort()<EOL>error_message = "<STR_LIT>".format(msgid=msgid)<EOL>error_message += "<STR_LIT>".format(<EOL>other_symbol=symbols[<NUM_LIT:0>], symbol=symbols[<NUM_LIT:1>]<EOL>)<EOL>raise InvalidMessageError(error_message)<EOL>

Raise an error when a symbol is duplicated.

        :param str msgid: The msgid corresponding to the symbols
        :param str symbol: Offending symbol
        :param str other_symbol: Other offending symbol
        :raises InvalidMessageError: when a symbol is duplicated.


@staticmethod<EOL><INDENT>def _raise_duplicate_msg_id(symbol, msgid, other_msgid):<DEDENT>

msgids = [msgid, other_msgid]<EOL>msgids.sort()<EOL>error_message = "<STR_LIT>".format(<EOL>symbol=symbol<EOL>)<EOL>error_message += "<STR_LIT>".format(<EOL>other_msgid=msgids[<NUM_LIT:0>], msgid=msgids[<NUM_LIT:1>]<EOL>)<EOL>raise InvalidMessageError(error_message)<EOL>

Raise an error when a msgid is duplicated.

        :param str symbol: The symbol corresponding to the msgids
        :param str msgid: Offending msgid
        :param str other_msgid: Other offending msgid
        :raises InvalidMessageError: when a msgid is duplicated.


def get_message_definitions(self, msgid_or_symbol: str) -> list:

if msgid_or_symbol[<NUM_LIT:1>:].isdigit():<EOL><INDENT>msgid_or_symbol = msgid_or_symbol.upper()<EOL><DEDENT>for source in (self._alternative_names, self._messages_definitions):<EOL><INDENT>try:<EOL><INDENT>return [source[msgid_or_symbol]]<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>error_msg = "<STR_LIT>".format(<EOL>msgid_or_symbol=msgid_or_symbol<EOL>)<EOL>raise UnknownMessageError(error_msg)<EOL>

Returns the Message object for this message.

        :param str msgid_or_symbol: msgid_or_symbol may be either a numeric or symbolic id.
        :raises UnknownMessageError: if the message id is not defined.
        :rtype: List of MessageDefinition
        :return: A message definition corresponding to msgid_or_symbol


message_definitions = self.get_message_definitions(msgid)<EOL>if len(message_definitions) == <NUM_LIT:1>:<EOL><INDENT>return repr(message_definitions[<NUM_LIT:0>].symbol)<EOL><DEDENT>return repr([md.symbol for md in message_definitions])<EOL>

Generates a user-consumable representation of a message.

        Can be just the message ID or the ID and the symbol.


for msgid in msgids:<EOL><INDENT>try:<EOL><INDENT>for message_definition in self.get_message_definitions(msgid):<EOL><INDENT>print(message_definition.format_help(checkerref=True))<EOL>print("<STR_LIT>")<EOL><DEDENT><DEDENT>except UnknownMessageError as ex:<EOL><INDENT>print(ex)<EOL>print("<STR_LIT>")<EOL>continue<EOL><DEDENT><DEDENT>

Display help messages for the given message identifiers


messages = sorted(self._messages_definitions.values(), key=lambda m: m.msgid)<EOL>for message in messages:<EOL><INDENT>if not message.may_be_emitted():<EOL><INDENT>continue<EOL><DEDENT>print(message.format_help(checkerref=False))<EOL><DEDENT>print("<STR_LIT>")<EOL>

Output full messages list documentation in ReST format.


<EOL>return template.format(**dict(zip(self._fields, self)))<EOL>

Format the message according to the given template.

        The template format is the one of the format method :
        cf. http://docs.python.org/2/library/string.html#formatstrings


if self.minversion is not None and self.minversion > sys.version_info:<EOL><INDENT>return False<EOL><DEDENT>if self.maxversion is not None and self.maxversion <= sys.version_info:<EOL><INDENT>return False<EOL><DEDENT>return True<EOL>

return True if message may be emitted using the current interpreter


desc = self.descr<EOL>if checkerref:<EOL><INDENT>desc += "<STR_LIT>" % self.checker.name<EOL><DEDENT>title = self.msg<EOL>if self.symbol:<EOL><INDENT>msgid = "<STR_LIT>" % (self.symbol, self.msgid)<EOL><DEDENT>else:<EOL><INDENT>msgid = self.msgid<EOL><DEDENT>if self.minversion or self.maxversion:<EOL><INDENT>restr = []<EOL>if self.minversion:<EOL><INDENT>restr.append("<STR_LIT>" % "<STR_LIT:.>".join([str(n) for n in self.minversion]))<EOL><DEDENT>if self.maxversion:<EOL><INDENT>restr.append("<STR_LIT>" % "<STR_LIT:.>".join([str(n) for n in self.maxversion]))<EOL><DEDENT>restr = "<STR_LIT>".join(restr)<EOL>if checkerref:<EOL><INDENT>desc += "<STR_LIT>" % restr<EOL><DEDENT>else:<EOL><INDENT>desc += "<STR_LIT>" % restr<EOL><DEDENT><DEDENT>desc = normalize_text("<STR_LIT:U+0020>".join(desc.split()), indent="<STR_LIT:U+0020>")<EOL>if title != "<STR_LIT:%s>":<EOL><INDENT>title = title.splitlines()[<NUM_LIT:0>]<EOL>return "<STR_LIT>" % (msgid, title.rstrip("<STR_LIT:U+0020>"), desc)<EOL><DEDENT>return "<STR_LIT>" % (msgid, desc)<EOL>

return the help string for the given message id


env = dict(os.environ)<EOL>env["<STR_LIT>"] = os.pathsep.join(sys.path)<EOL>return env<EOL>

Extracts the environment PYTHONPATH and appends the current sys.path to
    those.


<EOL>full_path = osp.abspath(filename)<EOL>parent_path = osp.dirname(full_path)<EOL>child_path = osp.basename(full_path)<EOL>while parent_path != "<STR_LIT:/>" and osp.exists(osp.join(parent_path, "<STR_LIT>")):<EOL><INDENT>child_path = osp.join(osp.basename(parent_path), child_path)<EOL>parent_path = osp.dirname(parent_path)<EOL><DEDENT>run_cmd = "<STR_LIT>"<EOL>cmd = (<EOL>[sys.executable, "<STR_LIT:-c>", run_cmd]<EOL>+ [<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT:n>",<EOL>child_path,<EOL>]<EOL>+ list(options)<EOL>)<EOL>process = Popen(<EOL>cmd, stdout=PIPE, cwd=parent_path, env=_get_env(), universal_newlines=True<EOL>)<EOL>for line in process.stdout:<EOL><INDENT>if line.startswith("<STR_LIT>"):<EOL><INDENT>continue<EOL><DEDENT>parts = line.split("<STR_LIT::>")<EOL>if parts and parts[<NUM_LIT:0>] == child_path:<EOL><INDENT>line = "<STR_LIT::>".join([filename] + parts[<NUM_LIT:1>:])<EOL><DEDENT>print(line, end="<STR_LIT:U+0020>")<EOL><DEDENT>process.wait()<EOL>return process.returncode<EOL>

Pylint the given file.

    When run from emacs we will be in the directory of a file, and passed its
    filename.  If this file is part of a package and is trying to import other
    modules from within its own package or another package rooted in a directory
    below it, pylint will classify it as a failed import.

    To get around this, we traverse down the directory tree to find the root of
    the package this module is in.  We then invoke pylint from this directory.

    Finally, we must correct the filenames in the output generated by pylint so
    Emacs doesn't become confused (it will expect just the original filename,
    while pylint may extend it with extra directories if we've traversed down
    the tree)


def py_run(command_options="<STR_LIT>", return_std=False, stdout=None, stderr=None):

<EOL>executable = sys.executable if "<STR_LIT>" in sys.executable else "<STR_LIT>"<EOL>epylint_part = [executable, "<STR_LIT:-c>", "<STR_LIT>"]<EOL>options = shlex.split(command_options, posix=not sys.platform.startswith("<STR_LIT>"))<EOL>cli = epylint_part + options<EOL>if stdout is None:<EOL><INDENT>if return_std:<EOL><INDENT>stdout = PIPE<EOL><DEDENT>else:<EOL><INDENT>stdout = sys.stdout<EOL><DEDENT><DEDENT>if stderr is None:<EOL><INDENT>if return_std:<EOL><INDENT>stderr = PIPE<EOL><DEDENT>else:<EOL><INDENT>stderr = sys.stderr<EOL><DEDENT><DEDENT>process = Popen(<EOL>cli,<EOL>shell=False,<EOL>stdout=stdout,<EOL>stderr=stderr,<EOL>env=_get_env(),<EOL>universal_newlines=True,<EOL>)<EOL>proc_stdout, proc_stderr = process.communicate()<EOL>if return_std:<EOL><INDENT>return StringIO(proc_stdout), StringIO(proc_stderr)<EOL><DEDENT>return None<EOL>

Run pylint from python

    ``command_options`` is a string containing ``pylint`` command line options;
    ``return_std`` (boolean) indicates return of created standard output
    and error (see below);
    ``stdout`` and ``stderr`` are 'file-like' objects in which standard output
    could be written.

    Calling agent is responsible for stdout/err management (creation, close).
    Default standard output and error are those from sys,
    or standalone ones (``subprocess.PIPE``) are used
    if they are not set and ``return_std``.

    If ``return_std`` is set to ``True``, this function returns a 2-uple
    containing standard output and error related to created process,
    as follows: ``(stdout, stderr)``.

    To silently run Pylint on a module, and get its standard output and error:
        >>> (pylint_stdout, pylint_stderr) = py_run( 'module_name.py', True)


linter.register_reporter(JSONReporter)<EOL>

Register the reporter classes with the linter.


self.messages.append(<EOL>{<EOL>"<STR_LIT:type>": msg.category,<EOL>"<STR_LIT>": msg.module,<EOL>"<STR_LIT>": msg.obj,<EOL>"<STR_LIT>": msg.line,<EOL>"<STR_LIT>": msg.column,<EOL>"<STR_LIT:path>": msg.path,<EOL>"<STR_LIT>": msg.symbol,<EOL>"<STR_LIT:message>": html.escape(msg.msg or "<STR_LIT>", quote=False),<EOL>"<STR_LIT>": msg.msg_id,<EOL>}<EOL>)<EOL>

Manage message of different type and in the context of path.


print(json.dumps(self.messages, indent=<NUM_LIT:4>), file=self.out)<EOL>


self.children.append(child)<EOL>child.parent = self<EOL>


self.children.insert(index, child)<EOL>child.parent = self<EOL>


try:<EOL><INDENT>return self.TYPE.replace("<STR_LIT:->", "<STR_LIT:_>")<EOL><DEDENT>except Exception:<EOL><INDENT>return self.__class__.__name__.lower()<EOL><DEDENT>

return the visit name for the mixed class. When calling 'accept', the
method <'visit_' + name returned by this method> will be called on the
visitor


assert child not in self.parents()<EOL>VNode.append(self, child)<EOL>


assert self.parent is not self<EOL>if self.parent is None:<EOL><INDENT>return []<EOL><DEDENT>return [self.parent] + self.parent.parents()<EOL>


self.children.append(Text(text))<EOL>


def format(self, layout, stream=None, encoding=None):

if stream is None:<EOL><INDENT>stream = sys.stdout<EOL><DEDENT>if not encoding:<EOL><INDENT>encoding = getattr(stream, "<STR_LIT>", "<STR_LIT>")<EOL><DEDENT>self.encoding = encoding or "<STR_LIT>"<EOL>self.out = stream<EOL>self.begin_format()<EOL>layout.accept(self)<EOL>self.end_format()<EOL>

format and write the given layout into the stream object

        unicode policy: unicode strings may be found in the layout;
        try to call stream.write with it, but give it back encoded using
        the given encoding if it fails


for child in getattr(layout, "<STR_LIT>", ()):<EOL><INDENT>child.accept(self)<EOL><DEDENT>

recurse on the layout children and call their accept method
        (see the Visitor pattern)


self.write(string + os.linesep)<EOL>


self.out.write(string)<EOL>


self.section = <NUM_LIT:0><EOL>


result = [[]]<EOL>cols = table.cols<EOL>for cell in self.compute_content(table):<EOL><INDENT>if cols == <NUM_LIT:0>:<EOL><INDENT>result.append([])<EOL>cols = table.cols<EOL><DEDENT>cols -= <NUM_LIT:1><EOL>result[-<NUM_LIT:1>].append(cell)<EOL><DEDENT>while len(result[-<NUM_LIT:1>]) < cols:<EOL><INDENT>result[-<NUM_LIT:1>].append("<STR_LIT>")<EOL><DEDENT>return result<EOL>

trick to get table content without actually writing it

        return an aligned list of lists containing table cells values as string


<EOL>out = self.out<EOL>try:<EOL><INDENT>for child in layout.children:<EOL><INDENT>stream = StringIO()<EOL>self.out = stream<EOL>child.accept(self)<EOL>yield stream.getvalue()<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>self.out = out<EOL><DEDENT>

trick to compute the formatting of children layout before actually
        writing it

        return an iterator on strings (one for each child element)


self.section += <NUM_LIT:1><EOL>self.writeln()<EOL>self.format_children(layout)<EOL>self.section -= <NUM_LIT:1><EOL>self.writeln()<EOL>


self.section += <NUM_LIT:1><EOL>self.format_children(layout)<EOL>self.section -= <NUM_LIT:1><EOL>self.writeln()<EOL>

Display an evaluation section as a text.


self.format_children(layout)<EOL>self.writeln()<EOL>


table_content = self.get_table_content(layout)<EOL>cols_width = [<NUM_LIT:0>] * len(table_content[<NUM_LIT:0>])<EOL>for row in table_content:<EOL><INDENT>for index, col in enumerate(row):<EOL><INDENT>cols_width[index] = max(cols_width[index], len(col))<EOL><DEDENT><DEDENT>self.default_table(layout, table_content, cols_width)<EOL>self.writeln()<EOL>


def default_table(self, layout, table_content, cols_width):

cols_width = [size + <NUM_LIT:1> for size in cols_width]<EOL>format_strings = "<STR_LIT:U+0020>".join(["<STR_LIT>"] * len(cols_width))<EOL>format_strings = format_strings % tuple(cols_width)<EOL>format_strings = format_strings.split("<STR_LIT:U+0020>")<EOL>table_linesep = "<STR_LIT>" + "<STR_LIT:+>".join(["<STR_LIT:->" * w for w in cols_width]) + "<STR_LIT>"<EOL>headsep = "<STR_LIT>" + "<STR_LIT:+>".join(["<STR_LIT:=>" * w for w in cols_width]) + "<STR_LIT>"<EOL>self.write(table_linesep)<EOL>for index, line in enumerate(table_content):<EOL><INDENT>self.write("<STR_LIT:|>")<EOL>for line_index, at_index in enumerate(line):<EOL><INDENT>self.write(format_strings[line_index] % at_index)<EOL>self.write("<STR_LIT:|>")<EOL><DEDENT>if index == <NUM_LIT:0> and layout.rheaders:<EOL><INDENT>self.write(headsep)<EOL><DEDENT>else:<EOL><INDENT>self.write(table_linesep)<EOL><DEDENT><DEDENT>


self.writeln("<STR_LIT>")<EOL>for line in layout.data.splitlines():<EOL><INDENT>self.writeln("<STR_LIT:U+0020>" + line)<EOL><DEDENT>self.writeln()<EOL>

display a verbatim layout as text (so difficult ;)


self.write("<STR_LIT:%s>" % layout.data)<EOL>


return list(self._reports)<EOL>

Return a list of reports, sorted in the order
        in which they must be called.


def register_report(self, reportid, r_title, r_cb, checker):

reportid = reportid.upper()<EOL>self._reports[checker].append((reportid, r_title, r_cb))<EOL>

register a report

        reportid is the unique identifier for the report
        r_title the report's title
        r_cb the method to call to make the report
        checker is the checker defining the report


reportid = reportid.upper()<EOL>self._reports_state[reportid] = True<EOL>


reportid = reportid.upper()<EOL>self._reports_state[reportid] = False<EOL>


return self._reports_state.get(reportid, True)<EOL>

return true if the report associated to the given identifier is
        enabled


def make_reports(self, stats, old_stats):

sect = Section("<STR_LIT>", "<STR_LIT>" % (self.stats["<STR_LIT>"]))<EOL>for checker in self.report_order():<EOL><INDENT>for reportid, r_title, r_cb in self._reports[checker]:<EOL><INDENT>if not self.report_is_enabled(reportid):<EOL><INDENT>continue<EOL><DEDENT>report_sect = Section(r_title)<EOL>try:<EOL><INDENT>r_cb(report_sect, stats, old_stats)<EOL><DEDENT>except EmptyReportError:<EOL><INDENT>continue<EOL><DEDENT>report_sect.report_id = reportid<EOL>sect.append(report_sect)<EOL><DEDENT><DEDENT>return sect<EOL>


for key, value in kwargs.items():<EOL><INDENT>if key[-<NUM_LIT:1>] == "<STR_LIT:_>":<EOL><INDENT>key = key[:-<NUM_LIT:1>]<EOL><DEDENT>assert key not in self.stats<EOL>self.stats[key] = value<EOL><DEDENT>return self.stats<EOL>

add some stats entries to the statistic dictionary
        raise an AssertionError if there is a key conflict


ansi_code = []<EOL>if style:<EOL><INDENT>style_attrs = utils._splitstrip(style)<EOL>for effect in style_attrs:<EOL><INDENT>ansi_code.append(ANSI_STYLES[effect])<EOL><DEDENT><DEDENT>if color:<EOL><INDENT>if color.isdigit():<EOL><INDENT>ansi_code.extend(["<STR_LIT>", "<STR_LIT:5>"])<EOL>ansi_code.append(color)<EOL><DEDENT>else:<EOL><INDENT>ansi_code.append(ANSI_COLORS[color])<EOL><DEDENT><DEDENT>if ansi_code:<EOL><INDENT>return ANSI_PREFIX + "<STR_LIT:;>".join(ansi_code) + ANSI_END<EOL><DEDENT>return "<STR_LIT>"<EOL>

return ansi escape code corresponding to color and style

    :type color: str or None
    :param color:
      the color name (see `ANSI_COLORS` for available values)
      or the color number when 256 colors are available

    :type style: str or None
    :param style:
      style string (see `ANSI_COLORS` for available values). To get
      several style effects at the same time, use a coma as separator.

    :raise KeyError: if an unexistent color or style identifier is given

    :rtype: str
    :return: the built escape code


def colorize_ansi(msg, color=None, style=None):

<EOL>if color is None and style is None:<EOL><INDENT>return msg<EOL><DEDENT>escape_code = _get_ansi_code(color, style)<EOL>if escape_code:<EOL><INDENT>return "<STR_LIT>" % (escape_code, msg, ANSI_RESET)<EOL><DEDENT>return msg<EOL>

colorize message by wrapping it with ansi escape codes

    :type msg: str or unicode
    :param msg: the message string to colorize

    :type color: str or None
    :param color:
      the color identifier (see `ANSI_COLORS` for available values)

    :type style: str or None
    :param style:
      style string (see `ANSI_COLORS` for available values). To get
      several style effects at the same time, use a coma as separator.

    :raise KeyError: if an unexistent color or style identifier is given

    :rtype: str or unicode
    :return: the ansi escaped string


linter.register_reporter(TextReporter)<EOL>linter.register_reporter(ParseableTextReporter)<EOL>linter.register_reporter(VSTextReporter)<EOL>linter.register_reporter(ColorizedTextReporter)<EOL>


self.writeln(msg.format(self._template))<EOL>

Convenience method to write a formated message with class default template


if msg.module not in self._modules:<EOL><INDENT>if msg.module:<EOL><INDENT>self.writeln("<STR_LIT>" % msg.module)<EOL>self._modules.add(msg.module)<EOL><DEDENT>else:<EOL><INDENT>self.writeln("<STR_LIT>")<EOL><DEDENT><DEDENT>self.write_message(msg)<EOL>

manage message of different type and in the context of path


print(file=self.out)<EOL>TextWriter().format(layout, self.out)<EOL>


try:<EOL><INDENT>return self.color_mapping[msg_id[<NUM_LIT:0>]]<EOL><DEDENT>except KeyError:<EOL><INDENT>return None, None<EOL><DEDENT>

Returns the tuple color, style associated with msg_id as defined
        in self.color_mapping


if msg.module not in self._modules:<EOL><INDENT>color, style = self._get_decoration("<STR_LIT:S>")<EOL>if msg.module:<EOL><INDENT>modsep = colorize_ansi(<EOL>"<STR_LIT>" % msg.module, color, style<EOL>)<EOL><DEDENT>else:<EOL><INDENT>modsep = colorize_ansi("<STR_LIT>" % msg.module, color, style)<EOL><DEDENT>self.writeln(modsep)<EOL>self._modules.add(msg.module)<EOL><DEDENT>color, style = self._get_decoration(msg.C)<EOL>msg = msg._replace(<EOL>**{<EOL>attr: colorize_ansi(getattr(msg, attr), color, style)<EOL>for attr in ("<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT:C>")<EOL>}<EOL>)<EOL>self.write_message(msg)<EOL>

manage message of different types, and colorize output
        using ansi escape codes


from pylint import utils<EOL>utils.register_plugins(linter, __path__[<NUM_LIT:0>])<EOL>

initialize linter with reporters in this package


Handle a new message triggered on the current file.


self.out = output or sys.stdout<EOL>


print(string, file=self.out)<EOL>


self.section = <NUM_LIT:0><EOL>if hasattr(layout, "<STR_LIT>"):<EOL><INDENT>layout.children[<NUM_LIT:0>].children[<NUM_LIT:0>].data += "<STR_LIT>" % layout.report_id<EOL><DEDENT>self._display(layout)<EOL>

display results encapsulated in the layout tree


raise NotImplementedError()<EOL>


Hook for displaying the messages of the reporter

        This will be called whenever the underlying messages
        needs to be displayed. For some reporters, it probably
        doesn't make sense to display messages as soon as they
        are available, so some mechanism of storing them could be used.
        This method can be implemented to display them after they've
        been aggregated.


def on_set_current_module(self, module, filepath):

Hook called when a module starts to be analysed.


def on_close(self, stats, previous_stats):

Hook called when a module finished analyzing.


kimplements = getattr(obj, "<STR_LIT>", ())<EOL>if not isinstance(kimplements, (list, tuple)):<EOL><INDENT>kimplements = (kimplements,)<EOL><DEDENT>for implementedinterface in kimplements:<EOL><INDENT>if issubclass(implementedinterface, interface):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>return False<EOL>

Return true if the give object (maybe an instance or class) implements
    the interface.


called before visiting project (i.e set of modules)


called after visiting project (i.e set of modules)


process a module

        the module's content is accessible via astroid.stream


Process a module.

        tokens is a list of all source code tokens in the file.


linter.register_checker(DocStringStyleChecker(linter))<EOL>

Required method to auto register this checker.

    :param linter: Main interface object for Pylint plugins
    :type linter: Pylint object


linter.register_checker(MultipleTypesChecker(linter))<EOL>


linter.register_checker(ElseifUsedChecker(linter))<EOL>


linter.register_checker(CompareToZeroChecker(linter))<EOL>

Required method to auto register this checker.


linter.register_checker(McCabeMethodChecker(linter))<EOL>


def _subgraph(self, node, name, extra_blocks=()):

if self.graph is None:<EOL><INDENT>self.graph = PathGraph(node)<EOL>self._subgraph_parse(node, node, extra_blocks)<EOL>self.graphs["<STR_LIT>" % (self.classname, name)] = self.graph<EOL>self.reset()<EOL><DEDENT>else:<EOL><INDENT>self._append_node(node)<EOL>self._subgraph_parse(node, node, extra_blocks)<EOL><DEDENT>

create the subgraphs representing any `if` and `for` statements


def _subgraph_parse(<EOL>self, node, pathnode, extra_blocks<EOL>):

loose_ends = []<EOL>self.tail = node<EOL>self.dispatch_list(node.body)<EOL>loose_ends.append(self.tail)<EOL>for extra in extra_blocks:<EOL><INDENT>self.tail = node<EOL>self.dispatch_list(extra.body)<EOL>loose_ends.append(self.tail)<EOL><DEDENT>if node.orelse:<EOL><INDENT>self.tail = node<EOL>self.dispatch_list(node.orelse)<EOL>loose_ends.append(self.tail)<EOL><DEDENT>else:<EOL><INDENT>loose_ends.append(node)<EOL><DEDENT>if node:<EOL><INDENT>bottom = "<STR_LIT:%s>" % self._bottom_counter<EOL>self._bottom_counter += <NUM_LIT:1><EOL>for le in loose_ends:<EOL><INDENT>self.graph.connect(le, bottom)<EOL><DEDENT>self.tail = bottom<EOL><DEDENT>

parse the body and any `else` block of `if` and `for` statements


visitor = PathGraphingAstVisitor()<EOL>for child in node.body:<EOL><INDENT>visitor.preorder(child, visitor)<EOL><DEDENT>for graph in visitor.graphs.values():<EOL><INDENT>complexity = graph.complexity()<EOL>node = graph.root<EOL>if hasattr(node, "<STR_LIT:name>"):<EOL><INDENT>node_name = "<STR_LIT>" % node.name<EOL><DEDENT>else:<EOL><INDENT>node_name = "<STR_LIT>" % node.__class__.__name__.lower()<EOL><DEDENT>if complexity <= self.config.max_complexity:<EOL><INDENT>continue<EOL><DEDENT>self.add_message(<EOL>"<STR_LIT>", node=node, confidence=HIGH, args=(node_name, complexity)<EOL>)<EOL><DEDENT>

visit an astroid.Module node to check too complex rating and
        add message if is greather than max_complexity stored from options


linter.register_checker(BroadTryClauseChecker(linter))<EOL>


linter.register_checker(BadBuiltinChecker(linter))<EOL>


linter.register_checker(DocstringParameterChecker(linter))<EOL>


node_doc = utils.docstringify(node.doc, self.config.default_docstring_type)<EOL>self.check_functiondef_params(node, node_doc)<EOL>self.check_functiondef_returns(node, node_doc)<EOL>self.check_functiondef_yields(node, node_doc)<EOL>

Called for function and method definitions (def).

        :param node: Node for a function or method definition in the AST
        :type node: :class:`astroid.scoped_nodes.Function`


def check_arguments_in_docstring(<EOL>self, doc, arguments_node, warning_node, accept_no_param_doc=None<EOL>):

<EOL>if not doc.doc:<EOL><INDENT>return<EOL><DEDENT>if accept_no_param_doc is None:<EOL><INDENT>accept_no_param_doc = self.config.accept_no_param_doc<EOL><DEDENT>tolerate_missing_params = doc.params_documented_elsewhere()<EOL>expected_argument_names = {arg.name for arg in arguments_node.args}<EOL>expected_argument_names.update(arg.name for arg in arguments_node.kwonlyargs)<EOL>not_needed_type_in_docstring = self.not_needed_param_in_docstring.copy()<EOL>if arguments_node.vararg is not None:<EOL><INDENT>expected_argument_names.add(arguments_node.vararg)<EOL>not_needed_type_in_docstring.add(arguments_node.vararg)<EOL><DEDENT>if arguments_node.kwarg is not None:<EOL><INDENT>expected_argument_names.add(arguments_node.kwarg)<EOL>not_needed_type_in_docstring.add(arguments_node.kwarg)<EOL><DEDENT>params_with_doc, params_with_type = doc.match_param_docs()<EOL>if not params_with_doc and not params_with_type and accept_no_param_doc:<EOL><INDENT>tolerate_missing_params = True<EOL><DEDENT>def _compare_missing_args(found_argument_names, message_id, not_needed_names):<EOL><INDENT>"""<STR_LIT>"""<EOL>if not tolerate_missing_params:<EOL><INDENT>missing_argument_names = (<EOL>expected_argument_names - found_argument_names<EOL>) - not_needed_names<EOL>if missing_argument_names:<EOL><INDENT>self.add_message(<EOL>message_id,<EOL>args=("<STR_LIT:U+002CU+0020>".join(sorted(missing_argument_names)),),<EOL>node=warning_node,<EOL>)<EOL><DEDENT><DEDENT><DEDENT>def _compare_different_args(found_argument_names, message_id, not_needed_names):<EOL><INDENT>"""<STR_LIT>"""<EOL>differing_argument_names = (<EOL>(expected_argument_names ^ found_argument_names)<EOL>- not_needed_names<EOL>- expected_argument_names<EOL>)<EOL>if differing_argument_names:<EOL><INDENT>self.add_message(<EOL>message_id,<EOL>args=("<STR_LIT:U+002CU+0020>".join(sorted(differing_argument_names)),),<EOL>node=warning_node,<EOL>)<EOL><DEDENT><DEDENT>_compare_missing_args(<EOL>params_with_doc, "<STR_LIT>", self.not_needed_param_in_docstring<EOL>)<EOL>for index, arg_name in enumerate(arguments_node.args):<EOL><INDENT>if arguments_node.annotations[index]:<EOL><INDENT>params_with_type.add(arg_name.name)<EOL><DEDENT><DEDENT>_compare_missing_args(<EOL>params_with_type, "<STR_LIT>", not_needed_type_in_docstring<EOL>)<EOL>_compare_different_args(<EOL>params_with_doc, "<STR_LIT>", self.not_needed_param_in_docstring<EOL>)<EOL>_compare_different_args(<EOL>params_with_type, "<STR_LIT>", not_needed_type_in_docstring<EOL>)<EOL>

Check that all parameters in a function, method or class constructor
        on the one hand and the parameters mentioned in the parameter
        documentation (e.g. the Sphinx tags 'param' and 'type') on the other
        hand are consistent with each other.

        * Undocumented parameters except 'self' are noticed.
        * Undocumented parameter types except for 'self' and the ``*<args>``
          and ``**<kwargs>`` parameters are noticed.
        * Parameters mentioned in the parameter documentation that don't or no
          longer exist in the function parameter list are noticed.
        * If the text "For the parameters, see" or "For the other parameters,
          see" (ignoring additional whitespace) is mentioned in the docstring,
          missing parameter documentation is tolerated.
        * If there's no Sphinx style, Google style or NumPy style parameter
          documentation at all, i.e. ``:param`` is never mentioned etc., the
          checker assumes that the parameters are documented in another format
          and the absence is tolerated.

        :param doc: Docstring for the function, method or class.
        :type doc: str

        :param arguments_node: Arguments node for the function, method or
            class constructor.
        :type arguments_node: :class:`astroid.scoped_nodes.Arguments`

        :param warning_node: The node to assign the warnings to
        :type warning_node: :class:`astroid.scoped_nodes.Node`

        :param accept_no_param_doc: Whether or not to allow no parameters
            to be documented.
            If None then this value is read from the configuration.
        :type accept_no_param_doc: bool or None


def _add_raise_message(self, missing_excs, node):

if node.is_abstract():<EOL><INDENT>try:<EOL><INDENT>missing_excs.remove("<STR_LIT>")<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if not missing_excs:<EOL><INDENT>return<EOL><DEDENT>self.add_message(<EOL>"<STR_LIT>", args=("<STR_LIT:U+002CU+0020>".join(sorted(missing_excs)),), node=node<EOL>)<EOL>

Adds a message on :param:`node` for the missing exception type.

:param missing_excs: A list of missing exception types.
:type missing_excs: set(str)

:param node: The node show the message on.
:type node: astroid.node_classes.NodeNG


return len(s) - len(s.lstrip("<STR_LIT:U+0020>"))<EOL>

The number of leading spaces in a string

    :param str s: input string

    :rtype: int
    :return: number of leading spaces


decorators = node.decorators.nodes if node.decorators else []<EOL>for decorator in decorators:<EOL><INDENT>if (<EOL>isinstance(decorator, astroid.Attribute)<EOL>and decorator.attrname == "<STR_LIT>"<EOL>and isinstance(decorator.expr, astroid.Name)<EOL>):<EOL><INDENT>return decorator.expr.name<EOL><DEDENT><DEDENT>return None<EOL>

Get the name of the property that the given node is a setter for.

    :param node: The node to get the property name for.
    :type node: str

    :rtype: str or None
    :returns: The name of the property that the node is a setter for,
        or None if one could not be found.


property_ = None<EOL>property_name = get_setters_property_name(node)<EOL>class_node = utils.node_frame_class(node)<EOL>if property_name and class_node:<EOL><INDENT>class_attrs = class_node.getattr(node.name)<EOL>for attr in class_attrs:<EOL><INDENT>if utils.decorated_with_property(attr):<EOL><INDENT>property_ = attr<EOL>break<EOL><DEDENT><DEDENT><DEDENT>return property_<EOL>

Get the property node for the given setter node.

    :param node: The node to get the property for.
    :type node: astroid.FunctionDef

    :rtype: astroid.FunctionDef or None
    :returns: The node relating to the property of the given setter node,
        or None if one could not be found.


returns = return_node.value<EOL>if returns is None:<EOL><INDENT>return False<EOL><DEDENT>return not (isinstance(returns, astroid.Const) and returns.value is None)<EOL>

Check if a return node returns a value other than None.

    :param return_node: The return node to check.
    :type return_node: astroid.Return

    :rtype: bool
    :return: True if the return node returns a value other than None,
        False otherwise.


excs = []<EOL>if isinstance(node.exc, astroid.Name):<EOL><INDENT>inferred = utils.safe_infer(node.exc)<EOL>if inferred:<EOL><INDENT>excs = [inferred.name]<EOL><DEDENT><DEDENT>elif node.exc is None:<EOL><INDENT>handler = node.parent<EOL>while handler and not isinstance(handler, astroid.ExceptHandler):<EOL><INDENT>handler = handler.parent<EOL><DEDENT>if handler and handler.type:<EOL><INDENT>inferred_excs = astroid.unpack_infer(handler.type)<EOL>excs = (exc.name for exc in inferred_excs if exc is not astroid.Uninferable)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>target = _get_raise_target(node)<EOL>if isinstance(target, astroid.ClassDef):<EOL><INDENT>excs = [target.name]<EOL><DEDENT>elif isinstance(target, astroid.FunctionDef):<EOL><INDENT>for ret in target.nodes_of_class(astroid.Return):<EOL><INDENT>if ret.frame() != target:<EOL><INDENT>continue<EOL><DEDENT>val = utils.safe_infer(ret.value)<EOL>if (<EOL>val<EOL>and isinstance(val, (astroid.Instance, astroid.ClassDef))<EOL>and utils.inherit_from_std_ex(val)<EOL>):<EOL><INDENT>excs.append(val.name)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>try:<EOL><INDENT>return {exc for exc in excs if not utils.node_ignores_exception(node, exc)}<EOL><DEDENT>except astroid.InferenceError:<EOL><INDENT>return set()<EOL><DEDENT>

Gets all of the possible raised exception types for the given raise node.

.. note::

    Caught exception types are ignored.

:param node: The raise node to find exception types for.
:type node: astroid.node_classes.NodeNG

:returns: A list of exception types possibly raised by :param:`node`.
:rtype: set(str)


linter.register_checker(CompareToEmptyStringChecker(linter))<EOL>


linter.register_checker(OverlappingExceptionsChecker(linter))<EOL>


for handler in node.handlers:<EOL><INDENT>if handler.type is None:<EOL><INDENT>continue<EOL><DEDENT>if isinstance(handler.type, astroid.BoolOp):<EOL><INDENT>continue<EOL><DEDENT>try:<EOL><INDENT>excs = list(_annotated_unpack_infer(handler.type))<EOL><DEDENT>except astroid.InferenceError:<EOL><INDENT>continue<EOL><DEDENT>handled_in_clause = []<EOL>for part, exc in excs:<EOL><INDENT>if exc is astroid.Uninferable:<EOL><INDENT>continue<EOL><DEDENT>if isinstance(exc, astroid.Instance) and utils.inherit_from_std_ex(exc):<EOL><INDENT>exc = exc._proxied<EOL><DEDENT>if not isinstance(exc, astroid.ClassDef):<EOL><INDENT>continue<EOL><DEDENT>exc_ancestors = [<EOL>anc for anc in exc.ancestors() if isinstance(anc, astroid.ClassDef)<EOL>]<EOL>for prev_part, prev_exc in handled_in_clause:<EOL><INDENT>prev_exc_ancestors = [<EOL>anc<EOL>for anc in prev_exc.ancestors()<EOL>if isinstance(anc, astroid.ClassDef)<EOL>]<EOL>if exc == prev_exc:<EOL><INDENT>self.add_message(<EOL>"<STR_LIT>",<EOL>node=handler.type,<EOL>args="<STR_LIT>"<EOL>% (prev_part.as_string(), part.as_string()),<EOL>)<EOL><DEDENT>elif prev_exc in exc_ancestors or exc in prev_exc_ancestors:<EOL><INDENT>ancestor = part if exc in prev_exc_ancestors else prev_part<EOL>descendant = part if prev_exc in exc_ancestors else prev_part<EOL>self.add_message(<EOL>"<STR_LIT>",<EOL>node=handler.type,<EOL>args="<STR_LIT>"<EOL>% (ancestor.as_string(), descendant.as_string()),<EOL>)<EOL><DEDENT><DEDENT>handled_in_clause += [(part, exc)]<EOL><DEDENT><DEDENT>


warnings.warn(<EOL>"<STR_LIT>",<EOL>DeprecationWarning,<EOL>)<EOL>linter.register_checker(docparams.DocstringParameterChecker(linter))<EOL>


first, second = <NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3> <EOL>return first + second<EOL>


first, second = [<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>] <EOL>return first + second<EOL>


(first, second) = <NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3> <EOL>return first + second<EOL>


first, second = range(<NUM_LIT:100>)<EOL>return first + second<EOL>


first, second = <NUM_LIT:1>, <NUM_LIT:2><EOL>return first + second<EOL>


first, second = (<NUM_LIT:1>, <NUM_LIT:2>)<EOL>return first + second<EOL>


(first, second) = (<NUM_LIT:1>, <NUM_LIT:2>)<EOL>return first + second<EOL>


if True:<EOL><INDENT>return [<NUM_LIT:1>, <NUM_LIT:2>]<EOL><DEDENT>return [<NUM_LIT:2>, <NUM_LIT:3>, <NUM_LIT:4>]<EOL>


first, second = temp()<EOL>return first + second<EOL>


if True:<EOL><INDENT>return (<NUM_LIT:1>, <NUM_LIT:2>)<EOL><DEDENT>if True:<EOL><INDENT>return (<NUM_LIT:2>, <NUM_LIT:3>)<EOL><DEDENT>return (<NUM_LIT:4>, <NUM_LIT:5>)<EOL>


first, second = temp2()<EOL>return first + second<EOL>


first, second = unpack() <EOL>return first + second<EOL>


first, second, third = args<EOL>return first, second, third<EOL>

Don't emit unbalanced tuple unpacking if the
    rhs of the assignment is a variable-length argument,
    because we don't know the actual length of the tuple.


return value<EOL>


def function9(value=[<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>, <NUM_LIT:4>]):

return value<EOL>

list with items should not output item values in error message


def function10(value={'<STR_LIT:a>': <NUM_LIT:1>, '<STR_LIT:b>': <NUM_LIT:2>}):

return value<EOL>

dictionaries with items should not output item values in error message


def function11(value=list([<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>])):

return value<EOL>


def function12(value=dict([('<STR_LIT:a>', <NUM_LIT:1>), ('<STR_LIT:b>', <NUM_LIT:2>)])):

return value<EOL>


def function14(value=dict([(<NUM_LIT:1>, <NUM_LIT:2>), (<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>)])):

return value<EOL>

a dictionary which will not be inferred to a syntax AST, but to an
    astroid.Instance.


try:<EOL><INDENT>raise ValueError('<STR_LIT:test>')<EOL><DEDENT>except ValueError:<EOL><INDENT>return <NUM_LIT:1><EOL><DEDENT>except ValueError:  <EOL><INDENT>return <NUM_LIT:2><EOL><DEDENT>except (OSError, TypeError):<EOL><INDENT>return <NUM_LIT:3><EOL><DEDENT>

The second ValueError should be flagged.


type = <NUM_LIT:1>  <EOL>print(type)<EOL>


Expects 0 args, but we are taking in account arguments with defaults.


print(self)<EOL>


return self<EOL>


return {key: str(value) for key, value in key.items()}<EOL>

Should not raise unused-argument message because key is
used inside comprehension dict


raise NotImplementedError<EOL>


return aaa<EOL>

overridden method, though don't use every argument


return self, aax<EOL>


return aaa + aab + aac<EOL>


with open("<STR_LIT>") as ctx.obj:  <EOL><INDENT>context.do()  <EOL>context = None<EOL><DEDENT>


var = nomoreknown  <EOL>assert var<EOL>


print(var, default)<EOL>print(xxxx)  <EOL>augvar += <NUM_LIT:1>  <EOL>del vardel<EOL>

function with defaut arg's value set to an unexistant name


return lambda: list(arg)<EOL>


@decorator(arg=[i * <NUM_LIT:2> for i in range(<NUM_LIT:15>)])<EOL>def func1():

A function with a decorator that contains a listcomp.


@decorator(arg=(i * <NUM_LIT:2> for i in range(<NUM_LIT:15>)))<EOL>def func2():

A function with a decorator that contains a genexpr.


@decorator(lambda x: x > <NUM_LIT:0>)<EOL>def main():

A function with a decorator that contains a lambda.


for i in range(<NUM_LIT:1>, number):<EOL><INDENT>yield i<EOL>await asyncio.sleep(<NUM_LIT:1>)<EOL><DEDENT>


async for i in some_iter_func(number):<EOL><INDENT>print(i)<EOL><DEDENT>


global CONSTANT  <EOL>print(CONSTANT)<EOL>CONSTANT = value<EOL>

all this is ok, but try not using global ;)


global HOP  <EOL>print(HOP)<EOL>


global SOMEVAR  <EOL>SOMEVAR = <NUM_LIT:2><EOL>

ok but somevar is not defined at the module scope


global sys  <EOL>import sys<EOL>


self.correct = <NUM_LIT:1><EOL>


"<STR_LIT>".format(<NUM_LIT:1>) <EOL>"<STR_LIT>".format() <EOL>"<STR_LIT>".format() <EOL>"<STR_LIT>".format(<NUM_LIT:1>, <NUM_LIT:2>) <EOL>"<STR_LIT>".format(a=<NUM_LIT:1>, c=<NUM_LIT:2>)<EOL>"<STR_LIT>".format(<NUM_LIT:1>, <NUM_LIT:2>) <EOL>"<STR_LIT>".format(<NUM_LIT:1>) <EOL>"<STR_LIT>".format(<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>) <EOL>"<STR_LIT>".format()<EOL>"<STR_LIT>".format(a=<NUM_LIT:1>, b=<NUM_LIT:2>) <EOL>"<STR_LIT>".format(<NUM_LIT:1>, <NUM_LIT:2>)<EOL>


bug2 = True<EOL>def on_click(event):<EOL><INDENT>"""<STR_LIT>"""<EOL>if event:<EOL><INDENT>nonlocal bug2<EOL>bug2 = not bug2<EOL><DEDENT><DEDENT>on_click(True)<EOL>


return fun<EOL>


return first_argument<EOL>


def function_3_args(first_argument, second_argument, third_argument):

return first_argument, second_argument, third_argument<EOL>


return two, one<EOL>


return arg + arg<EOL>


return (self, arg)<EOL>


def check_kwargs_before_args(param1, param2=<NUM_LIT:2>, *args):

pass<EOL>


def func_in_class(self, param1, param2=<NUM_LIT:2>, *args):

pass<EOL>


@staticmethod<EOL><INDENT>def static_method_in_class(param1, param2=<NUM_LIT:3>, *args): <DEDENT>

pass<EOL>


@classmethod<EOL><INDENT>def class_method_in_class(cls, param1, param2=<NUM_LIT:4>, *args): <DEDENT>

pass<EOL>


return arg1.value + arg2<EOL>


return (<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>)<EOL>


return <NUM_LIT:1><EOL>


pass<EOL>

This is a docstring.

    That contains a very, very long line that exceeds the 100 characters limit by a good margin. So good?


return parameter<EOL>


return TESTLIST[id]<EOL>


return TESTLIST[None]<EOL>


return TESTLIST[float(<NUM_LIT:0>)]<EOL>


return TESTLIST['<STR_LIT:0>']<EOL>


class NonIndexType(object):<EOL><INDENT>"""<STR_LIT>"""<EOL>pass<EOL><DEDENT>return TESTLIST[NonIndexType()]<EOL>


return TESTTUPLE[None]<EOL>


return TESTSTR[None]<EOL>


class TupleTest(tuple):<EOL><INDENT>"""<STR_LIT>"""<EOL>pass<EOL><DEDENT>return TupleTest()[None]<EOL>


return TESTLIST[<NUM_LIT:0>]<EOL>


return TESTLIST[int(<NUM_LIT:0.0>)]<EOL>


return TESTLIST[slice(<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>)]<EOL>


class IndexType(object):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __index__(self):<EOL><INDENT>"""<STR_LIT>"""<EOL>return <NUM_LIT:0><EOL><DEDENT><DEDENT>return TESTLIST[IndexType()]<EOL>


class IndexType(object):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __index__(self):<EOL><INDENT>"""<STR_LIT>"""<EOL>return <NUM_LIT:0><EOL><DEDENT><DEDENT>class IndexSubType(IndexType):<EOL><INDENT>"""<STR_LIT>"""<EOL>pass<EOL><DEDENT>return TESTLIST[IndexSubType()]<EOL>

list index implements __index__ in a superclass


return TESTTUPLE[<NUM_LIT:0>]<EOL>


return TESTSTR[<NUM_LIT:0>]<EOL>


class TupleTest(tuple):<EOL><INDENT>"""<STR_LIT>"""<EOL>pass<EOL><DEDENT>return TupleTest()[<NUM_LIT:0>]<EOL>

Index of subclass of tuple is an int constant


class TupleTest(tuple):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __getitem__(self, index):<EOL><INDENT>"""<STR_LIT>"""<EOL>return <NUM_LIT:0><EOL><DEDENT><DEDENT>return TupleTest()[None]<EOL>

Index of subclass of tuple with custom __getitem__ is None


class TupleTest(tuple):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __getitem__(self, index):<EOL><INDENT>"""<STR_LIT>"""<EOL>return <NUM_LIT:0><EOL><DEDENT><DEDENT>class SubTupleTest(TupleTest):<EOL><INDENT>"""<STR_LIT>"""<EOL>pass<EOL><DEDENT>return SubTupleTest()[None]<EOL>

Index of subclass of tuple with __getitem__ in superclass is None


TESTLIST[None] = <NUM_LIT:0> <EOL>TESTLIST[<NUM_LIT:0>] = <NUM_LIT:0><EOL>


del TESTLIST[None] <EOL>del TESTLIST[<NUM_LIT:0>]<EOL>


class ListTest(list):<EOL><INDENT>"""<STR_LIT>"""<EOL>pass<EOL><DEDENT>test = ListTest()<EOL>test[None] = <NUM_LIT:0> <EOL>del test[None] <EOL>test[<NUM_LIT:0>] = <NUM_LIT:0> <EOL>del test[<NUM_LIT:0>]<EOL>


class ListTest(list):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __setitem__(self, key, value):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>test = ListTest()<EOL>test[None][<NUM_LIT:0>] = <NUM_LIT:0> <EOL>del test[None] <EOL>test[<NUM_LIT:0>][<NUM_LIT:0>] = <NUM_LIT:0> <EOL>test[None] = <NUM_LIT:0> <EOL>test[<NUM_LIT:0>] = <NUM_LIT:0> <EOL>del test[<NUM_LIT:0>]<EOL>

Get, set, and delete on a subclass of list that overrides __setitem__


class ListTest(list):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __delitem__(self, key):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>test = ListTest()<EOL>test[None][<NUM_LIT:0>] = <NUM_LIT:0> <EOL>test[None] = <NUM_LIT:0>  <EOL>test[<NUM_LIT:0>][<NUM_LIT:0>] = <NUM_LIT:0> <EOL>test[<NUM_LIT:0>] = <NUM_LIT:0> <EOL>del test[None] <EOL>del test[<NUM_LIT:0>]<EOL>

Get, set, and delete on a subclass of list that overrides __delitem__


class ListTest(list):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __getitem__(self, key):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>test = ListTest()<EOL>test[None] = <NUM_LIT:0> <EOL>del test[None] <EOL>test[None][<NUM_LIT:0>] = <NUM_LIT:0> <EOL>test[<NUM_LIT:0>][<NUM_LIT:0>] = <NUM_LIT:0> <EOL>test[<NUM_LIT:0>] = <NUM_LIT:0> <EOL>del test[<NUM_LIT:0>]<EOL>

Get, set, and delete on a subclass of list that overrides __getitem__


return TESTLIST[..., <NUM_LIT:0>]<EOL>


class ExtSliceTest(object):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __getitem__(self, index):<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT><DEDENT>return ExtSliceTest()[..., <NUM_LIT:0>]<EOL>

Extended slice used with an object that implements __getitem__


class UnknownBase(Unknown):<EOL><INDENT>pass<EOL><DEDENT>slices = UnknownBase["<STR_LIT>"] + UnknownBase()[object]<EOL>ext_slices = UnknownBase[..., <NUM_LIT:0>] + UnknownBase()[..., <NUM_LIT:0>]<EOL>return slices, ext_slices<EOL>

Don't warn in the case where the indexed object has unknown base classes.


class Meta(type):<EOL><INDENT>def __getitem__(cls, arg):<EOL><INDENT>return <NUM_LIT><EOL><DEDENT><DEDENT>@six.add_metaclass(Meta)<EOL>class Works(object):<EOL><INDENT>pass<EOL><DEDENT>@six.add_metaclass(Meta)<EOL>class Error(list):<EOL><INDENT>pass<EOL><DEDENT>return Works['<STR_LIT:hello>'] + Error['<STR_LIT:hello>']<EOL>

Don't emit for classes with the right implementation.


raise KeyError('<STR_LIT>', arg)<EOL>

Raising a percent-formatted string and an argument


raise KeyError('<STR_LIT>' % arg)<EOL>

Instead of passing multiple arguments, format the message


raise ValueError('<STR_LIT>', name, value)<EOL>

Raising a formatted string and multiple additional arguments


raise ValueError('<STR_LIT>' % (name, value))<EOL>

The arguments have to be written as a tuple for formatting


raise KeyError('<STR_LIT>', arg)<EOL>


raise KeyError('<STR_LIT>'.format(arg))<EOL>


raise AssertionError(  <EOL>'<STR_LIT>'<EOL>"<STR_LIT>", arg)<EOL>


raise AssertionError(  <EOL>'''<STR_LIT>''', arg)<EOL>


raise ValueError(u'<STR_LIT>', arg)<EOL>


import standard_exceptions  <EOL>raise standard_exceptions.MyException(u'<STR_LIT>', arg)<EOL>

Regression test for nodes without .node attribute


return reversed(seq)<EOL>

This can't be infered at this moment,
    make sure we don't have a false positive.


bar_ = lala<EOL>


bar_ = <NUM_LIT:10><EOL>


self = lala<EOL>


cls = '<STR_LIT>'<EOL>


lala = <NUM_LIT:10><EOL>


def _set_param(param):<EOL><INDENT>nonlocal self<EOL>self = param  <EOL><DEDENT>_set_param(param)<EOL>return self<EOL>

This function uses nonlocal to reassign self


instance = MyClass()<EOL>for i in range(<NUM_LIT:10>):<EOL><INDENT>if <NUM_LIT:5> <= i:  <EOL><INDENT>pass<EOL><DEDENT>if <NUM_LIT:1> == i:  <EOL><INDENT>pass<EOL><DEDENT>if <NUM_LIT:3> < dummy_return():  <EOL><INDENT>pass<EOL><DEDENT>if <NUM_LIT:4> != instance.dummy_return():  <EOL><INDENT>pass<EOL><DEDENT>if <NUM_LIT:1> == instance.attr:  <EOL><INDENT>pass<EOL><DEDENT>if "<STR_LIT>" == instance.attr: <EOL><INDENT>pass<EOL><DEDENT><DEDENT>


for i in range(<NUM_LIT:10>):<EOL><INDENT>if i == <NUM_LIT:5>:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>


counter = <NUM_LIT:1><EOL>while True:<EOL><INDENT>counter += <NUM_LIT:1><EOL>if counter == <NUM_LIT:100>:<EOL><INDENT>return <NUM_LIT:7><EOL><DEDENT><DEDENT>

Don't check inconsistent return statements inside while loop


raise NotImplementedError()<EOL>


return trop<EOL>


return self<EOL>


try:<EOL><INDENT>pass<EOL><DEDENT>except IOError as xxx_todo_changeme:  <EOL><INDENT>(errno, message) = xxx_todo_changeme.args  <EOL>print(errno, message)  <EOL><DEDENT>except IOError as xxx_todo_changeme1:  <EOL><INDENT>(new_style, tuple) = xxx_todo_changeme1.args  <EOL>print(new_style, tuple)<EOL><DEDENT>


super(Aaaa, self).hop()<EOL>


super(NewAaaa, self).hop()<EOL>


def wrapper(self, *args, **kw):<EOL><INDENT>func(self, *args, **kw)<EOL>return <NUM_LIT><EOL><DEDENT>return wrapper<EOL>

Decorate *fn* to return ``self`` to enable chained method calls.


return true_value if condition else false_value<EOL>


return condition and true_value or false_value<EOL>


truth_value = <NUM_LIT><EOL>return condition and truth_value or false_value<EOL>

Using a Name as a condition but still emits


if text:<EOL><INDENT>yield "<STR_LIT>" % text<EOL>yield "<STR_LIT>"<EOL>yield "<STR_LIT>"<EOL>yield "<STR_LIT>"<EOL>yield "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>yield "<STR_LIT>"<EOL>yield "<STR_LIT>"<EOL>yield "<STR_LIT>"<EOL>yield "<STR_LIT>"<EOL>yield "<STR_LIT>"<EOL><DEDENT>


return arg.format(<NUM_LIT>)<EOL>


TextWriter.format(arg)<EOL>


TextWriter().format(arg)<EOL>


print(file=self.out)<EOL>TextWriter().format(layout, self.out)<EOL>


self.var = <NUM_LIT:1><EOL>

A method without a self argument, but usage.


self.var = "<STR_LIT>"<EOL>


hophop = not data<EOL>troptrop = True if data else False<EOL>toptop = data or True<EOL>return hophop, troptrop, toptop<EOL>


try:<EOL><INDENT>variable = <NUM_LIT:1><EOL>yield variable<EOL><DEDENT>finally:<EOL><INDENT>variable = <NUM_LIT:2><EOL>yield variable<EOL><DEDENT>

Test that a variable defined in a finally clause does not trigger a false positive


raise NotImplementedError()<EOL>


<EOL>")<EOL>


lst = []<EOL>for i in range(<NUM_LIT:10>):<EOL><INDENT>lst.append(i)<EOL><DEDENT>


return [i for i in range(<NUM_LIT:10>)]<EOL>


lst = []<EOL>for i in range(<NUM_LIT:10>):<EOL><INDENT>lst.append(lambda i=i: i)<EOL><DEDENT>


lst = []<EOL>for i in range(<NUM_LIT:10>):<EOL><INDENT>print(i)<EOL>lst.append(lambda i: i)<EOL><DEDENT>


return (i for i in range(<NUM_LIT:10>))<EOL>


for i in range(<NUM_LIT:10>):<EOL><INDENT>if i == <NUM_LIT:8>:<EOL><INDENT>return lambda: i<EOL><DEDENT><DEDENT>return lambda: -<NUM_LIT:1><EOL>

Accept use of the variable inside return.


for i in range(<NUM_LIT:10>):<EOL><INDENT>print((lambda x: i + x)(<NUM_LIT:1>))<EOL><DEDENT>


funs = []<EOL>for i in range(<NUM_LIT:10>):<EOL><INDENT>def func(bound_i=i):<EOL><INDENT>"""<STR_LIT>"""<EOL>return bound_i<EOL><DEDENT>funs.append(func)<EOL><DEDENT>return funs<EOL>

Another eager binding of the cell variable.


lst = []<EOL>for i in range(<NUM_LIT:10>):<EOL><INDENT>print(i)<EOL>lst.append(lambda: i)<EOL><DEDENT>


return [lambda: i for i in range(<NUM_LIT:10>)]<EOL>


lst = []<EOL>for i in range(<NUM_LIT:10>):<EOL><INDENT>j = i * i<EOL>lst.append(lambda: j)  <EOL><DEDENT>return lst<EOL>


lst = []<EOL>for i in range(<NUM_LIT:10>):<EOL><INDENT>def nested():<EOL><INDENT>"""<STR_LIT>"""<EOL>return i**<NUM_LIT:2>  <EOL><DEDENT>lst.append(nested)<EOL><DEDENT>return lst<EOL>


return (lambda: i for i in range(<NUM_LIT:10>))<EOL>

Problematic case.

    If this function is used as

    >>> [x() for x in bad_case5()]

    it behaves 'as expected', i.e. the result is range(10).

    If it's used with

    >>> lst = list(bad_case5())
    >>> [x() for x in lst]

    the result is [9] * 10 again.


lst = []<EOL>for i, j in zip(range(<NUM_LIT:10>), range(<NUM_LIT:10>, <NUM_LIT:20>)):<EOL><INDENT>print(j)<EOL>lst.append(lambda: i)  <EOL><DEDENT>return lst<EOL>


import x<EOL>


In Python, stubbed functions often have a body that contains just a
    single `pass` statement, indicating that the function doesn't do
    anything. However, a stubbed function can also have just a
    docstring, and function with a docstring and no body also does
    nothing.


pass<EOL>

This function doesn't do anything, but it has a docstring, so its
    `pass` statement is useless clutter.

    NEW CHECK: useless-pass

    This would check for stubs with both docstrings and `pass`
    statements, suggesting the removal of the useless `pass`
    statements


GoodClass()<EOL>SecondGoodClass()<EOL>ThirdGoodClass()<EOL>FourthGoodClass()<EOL>BadClass() <EOL>SecondBadClass() <EOL>ThirdBadClass() <EOL>FourthBadClass()<EOL>


print(value)<EOL>


def inner():<EOL><INDENT>return <NUM_LIT><EOL><DEDENT>return inner()<EOL>


pass<EOL>


exc = None<EOL>try:<EOL><INDENT>{}["<STR_LIT:a>"]<EOL><DEDENT>except KeyError as xxx_todo_changeme: <EOL><INDENT>exceptions.RuntimeError = xxx_todo_changeme <EOL>pass<EOL><DEDENT>except KeyError as OSError: <EOL><INDENT>pass<EOL><DEDENT>except KeyError as MyError: <EOL><INDENT>pass<EOL><DEDENT>except KeyError as exc: <EOL><INDENT>print(exc)<EOL><DEDENT>except KeyError as exc1: <EOL><INDENT>print(exc1)<EOL><DEDENT>except KeyError as FOO: <EOL><INDENT>print(FOO)<EOL><DEDENT>try:<EOL><INDENT>pass<EOL><DEDENT>except KeyError as exc1: <EOL><INDENT>print(exc1)<EOL><DEDENT>


def kwonly_1(self, first, *, second, third):

Normal positional with two positional only params.


def kwonly_4(self, *, first, second=None):

One positional only and another with a default.


One positional and only one positional only param.


Only one positional parameter instead of two positional only parameters.


self.set_later = value<EOL>

set set_later attribute (introduce an inference ambiguity)


return "<STR_LIT>"<EOL>


...<EOL>

Test that an Ellipsis as a body does not trigger the error


return Good3<EOL>


partial_func = partial(root_function, <NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>)<EOL>partial_func()<EOL>return root_function(<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>)<EOL>

Test we don't emit a FP for https://github.com/PyCQA/pylint/issues/2588


return Sub(), self<EOL>


yield self.val<EOL>


with self.gen():  <EOL><INDENT>pass<EOL><DEDENT>


return TESTLIST[id:id:]<EOL>


return TESTLIST['<STR_LIT:0>':'<STR_LIT:1>':]<EOL>


class NoIndexTest(object):<EOL><INDENT>"""<STR_LIT>"""<EOL>pass<EOL><DEDENT>return TESTLIST[NoIndexTest()::]<EOL>


return TESTLIST[<NUM_LIT:0>:<NUM_LIT:0>:<NUM_LIT:0>]<EOL>


return TESTLIST[None:None:None]<EOL>


class IndexTest(object):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __index__(self):<EOL><INDENT>"""<STR_LIT>"""<EOL>return <NUM_LIT:0><EOL><DEDENT><DEDENT>return TESTLIST[IndexTest():None:None]<EOL>


class IndexType(object):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __index__(self):<EOL><INDENT>"""<STR_LIT>"""<EOL>return <NUM_LIT:0><EOL><DEDENT><DEDENT>class IndexSubType(IndexType):<EOL><INDENT>"""<STR_LIT>"""<EOL>pass<EOL><DEDENT>return TESTLIST[IndexSubType():None:None]<EOL>

class with __index__ in superclass used as index


return TESTLIST[slice(<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>)]<EOL>


class StringSlice:<EOL><INDENT>def __getitem__(self, item):<EOL><INDENT>return item<EOL><DEDENT><DEDENT>StringSlice()["<STR_LIT:a>":"<STR_LIT:b>":"<STR_LIT:c>"]<EOL>StringSlice()["<STR_LIT:a>":"<STR_LIT:b>":"<STR_LIT:c>", "<STR_LIT:a>":"<STR_LIT:b>"]<EOL>StringSlice()[slice("<STR_LIT:a>", "<STR_LIT:b>", "<STR_LIT:c>")]<EOL>

Use a custom class that knows how to handle string slices


if True:<EOL><INDENT>return [<NUM_LIT:1>, <NUM_LIT:2>]<EOL><DEDENT>else:<EOL><INDENT>return (<NUM_LIT:3>, <NUM_LIT:4>)<EOL><DEDENT>


return good_unpacking()<EOL>


raise NotImplementedError<EOL>


self.setup_pair()<EOL>x, y = self.pair<EOL>

error should not be emitted because setup_pair is abstract


import socket<EOL>sckt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<EOL>sckt.connect(('<STR_LIT:127.0.0.1>', <NUM_LIT>))<EOL>sckt.close()<EOL>

Test a regression
    Version used:

    - Pylint 0.10.0
    - Logilab common 0.15.0
    - Logilab astroid 0.15.1

    False E1101 positive, line 23:
    Instance of '_socketobject' has no 'connect' member


if magic_flag:<EOL><INDENT>something = <NUM_LIT:1.0><EOL><DEDENT>else:<EOL><INDENT>something = <NUM_LIT><EOL><DEDENT>if isinstance(something, float):<EOL><INDENT>return something<EOL><DEDENT>return something.conjugate()<EOL>

should not raise E1101 on something.conjugate


return self.attr * val<EOL>


print('<STR_LIT>', self)<EOL>


self.set_later = value<EOL>


self._prov.hophop()<EOL>self._prov.hophophop()<EOL>


print(self._prov.attr)<EOL>print(self._prov.attribute)<EOL>


print(self.__class__.__name__)<EOL>print(self.__doc__)<EOL>print(self.__dict__)<EOL>print(self.__module__)<EOL>


return <NUM_LIT:1><EOL>

Infinite iterator, but still an iterator


return <NUM_LIT:1><EOL>


pass<EOL>


cls._cls_protected += <NUM_LIT:1><EOL>print(cls._cls_protected)<EOL>


return type(self)._attr<EOL>


if self._attr == <NUM_LIT:1>:<EOL><INDENT>return type(INST)._protected  <EOL><DEDENT>return None<EOL>


raise ValidException('<STR_LIT>')<EOL>


import zlib<EOL>raise zlib.error(<NUM_LIT:4>)<EOL>


import decimal<EOL>raise decimal.DivisionByZero(<NUM_LIT:4>)<EOL>

decimal.DivisionByZero is defined in C on Python 3.


import io<EOL>raise io.BlockingIOError<EOL>


<EOL>raise OldStyleClass('<STR_LIT>')<EOL>


raise NewStyleClass()<EOL>


raise NewStyleClass<EOL>


raise NotImplemented('<STR_LIT>')<EOL>


raise <NUM_LIT:1><EOL>


raise None<EOL>


raise list<EOL>


raise tuple<EOL>


raise dict<EOL>


from lala import bala<EOL>class MyException(bala):<EOL><INDENT>pass<EOL><DEDENT>raise MyException<EOL>

Don't emit when we don't know the bases.


try:<EOL><INDENT>int("<STR_LIT>")<EOL><DEDENT>except ValueError as exc:<EOL><INDENT>raise exc<EOL><DEDENT>


return message<EOL>


"<STR_LIT>".format(<NUM_LIT:1>) <EOL>"<STR_LIT>".format() <EOL>"<STR_LIT>".format() <EOL>"<STR_LIT>".format(<NUM_LIT:1>, <NUM_LIT:2>) <EOL>"<STR_LIT>".format(a=<NUM_LIT:1>, c=<NUM_LIT:2>)<EOL>"<STR_LIT>".format(<NUM_LIT:1>, <NUM_LIT:2>) <EOL>"<STR_LIT>".format(<NUM_LIT:1>) <EOL>"<STR_LIT>".format(<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>) <EOL>"<STR_LIT>".format()<EOL>"<STR_LIT>".format(a=<NUM_LIT:1>, b=<NUM_LIT:2>) <EOL>"<STR_LIT>".format(<NUM_LIT:1>, <NUM_LIT:2>)<EOL>"<STR_LIT>".format(<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>) <EOL>"<STR_LIT>".format(a=Test())<EOL>"<STR_LIT>".format(a=Test()) <EOL>"<STR_LIT>".format(a=Test()) <EOL>"<STR_LIT>".format(["<STR_LIT:a>"]) <EOL>"<STR_LIT>".format(((<NUM_LIT:1>, ))) <EOL>"<STR_LIT>".format(a=<NUM_LIT>)<EOL>"<STR_LIT>".format(a=object) <EOL>log("<STR_LIT:{}>".format(<NUM_LIT:2>, "<STR_LIT:info>")) <EOL>"<STR_LIT>".format(<NUM_LIT:2>) <EOL>"<STR_LIT>".format(<NUM_LIT:1>, <NUM_LIT:2>) <EOL>"<STR_LIT>".format(<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>) <EOL>"<STR_LIT>".format(a=<NUM_LIT:4>) <EOL>"<STR_LIT>".format([<NUM_LIT:4>]) <EOL>"<STR_LIT>".format([<NUM_LIT:4>], <NUM_LIT:5>, <NUM_LIT:6>)<EOL>


'<STR_LIT>'.format(args)<EOL>'<STR_LIT>'.format(kwargs)<EOL>

Test that using kwargs does not emit a false
    positive.


name = '<STR_LIT>'<EOL>ret = {'<STR_LIT>': '<STR_LIT>'}<EOL>ret['<STR_LIT>'] = '<STR_LIT>'<EOL>ret['<STR_LIT>'] = ret['<STR_LIT>'].format(name)<EOL>return ret, name<EOL>

Test that the string format checker skips
    format nodes which don't have a string as a parent
    (but a subscript, name etc).


'<STR_LIT>'.format(<NUM_LIT>, <NUM_LIT>)<EOL>'<STR_LIT>'.format(<NUM_LIT:1>, a=[<NUM_LIT:1>, <NUM_LIT:2>])<EOL>'<STR_LIT>'.format(<NUM_LIT>, <NUM_LIT>)<EOL>'<STR_LIT>'.format(<NUM_LIT>) <EOL>'<STR_LIT>'.format(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>) <EOL>'<STR_LIT>'.format(<NUM_LIT:1>) <EOL>'<STR_LIT>'.format(<NUM_LIT:1>, a=<NUM_LIT:2>)<EOL>


'<STR_LIT>'.format(<NUM_LIT:1>, <NUM_LIT:2>)<EOL>'<STR_LIT>'.format(<NUM_LIT:1>)<EOL>

Test a regression using duplicate manual position arguments.


'<STR_LIT>'.format(<NUM_LIT>, {'<STR_LIT>': <NUM_LIT>})<EOL>'<STR_LIT>'.format(<NUM_LIT>, {'<STR_LIT>': <NUM_LIT>}, <NUM_LIT>) <EOL>'<STR_LIT>'.format(<NUM_LIT>)<EOL>

Test a regression using mixed manual position arguments
    and attribute access arguments.


from collections import namedtuple<EOL>class Crash(namedtuple("<STR_LIT:C>", "<STR_LIT>")):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __str__(self):<EOL><INDENT>return "<STR_LIT>".format(self)<EOL><DEDENT><DEDENT>return Crash<EOL>

Check that using a namedtuple subclass doesn't crash when
trying to infer EmptyNodes (resulted after mocking the
members of namedtuples).


fmt = '<STR_LIT>'.format<EOL>fmt('<STR_LIT>') <EOL>fmt('<STR_LIT>', '<STR_LIT>')<EOL>fmt('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>

Check that the format method can be assigned to a variable, ie:


class SomeClass(object):<EOL><INDENT>"""<STR_LIT>"""<EOL>def __init__(self, opts=None):<EOL><INDENT>self.opts = opts<EOL><DEDENT>def dunc(self, arg):<EOL><INDENT>"""<STR_LIT>"""<EOL>return "<STR_LIT>".format(arg, self.opts)<EOL><DEDENT>def func(self):<EOL><INDENT>"""<STR_LIT>"""<EOL>return '<STR_LIT>'.format(self.opts)<EOL><DEDENT><DEDENT>return SomeClass<EOL>

Ignore any object coming from an argument.


data = "<STR_LIT>".format(<NUM_LIT>)<EOL>data2 = "<STR_LIT>".format([<NUM_LIT:1>])<EOL>return (data, data2)<EOL>

Mix positional arguments, `{0}`, with positional
arguments with attribute access, `{0.__x__}`.


return "<STR_LIT>".format(<NUM_LIT:1>)<EOL>

The following string is invalid, avoid crashing.


__revision__ = <NUM_LIT:1> <EOL>return __revision__<EOL>


def callback():<EOL><INDENT>"""<STR_LIT>"""<EOL>pass<EOL><DEDENT>return callback<EOL>


division = <NUM_LIT:2><EOL>return division<EOL>

Don't emit if we defined a variable with the same name as a
    __future__ directive.


pass<EOL>


pass<EOL>

Second dummy function, don't emit function-redefined message
    because of the dummy name


bool_var = True<EOL>someint = <NUM_LIT:2><EOL>if not not bool_var:  <EOL><INDENT>pass<EOL><DEDENT>if not someint == <NUM_LIT:1>:  <EOL><INDENT>pass<EOL><DEDENT>if not someint != <NUM_LIT:1>:  <EOL><INDENT>pass<EOL><DEDENT>if not someint < <NUM_LIT:1>:  <EOL><INDENT>pass<EOL><DEDENT>if not someint > <NUM_LIT:1>:  <EOL><INDENT>pass<EOL><DEDENT>if not someint <= <NUM_LIT:1>:  <EOL><INDENT>pass<EOL><DEDENT>if not someint >= <NUM_LIT:1>:  <EOL><INDENT>pass<EOL><DEDENT>if not not someint:  <EOL><INDENT>pass<EOL><DEDENT>if not bool_var == True:  <EOL><INDENT>pass<EOL><DEDENT>if not bool_var == False:  <EOL><INDENT>pass<EOL><DEDENT>if not bool_var != True:  <EOL><INDENT>pass<EOL><DEDENT>if not True == True:  <EOL><INDENT>pass<EOL><DEDENT>if not <NUM_LIT:2> in [<NUM_LIT:3>, <NUM_LIT:4>]:  <EOL><INDENT>pass<EOL><DEDENT>if not someint is '<STR_LIT:test>':  <EOL><INDENT>pass<EOL><DEDENT>


bool_var = True<EOL>someint = <NUM_LIT:2><EOL>if not(bool_var == False and someint == <NUM_LIT:1>):<EOL><INDENT>pass<EOL><DEDENT>if <NUM_LIT:2> not in [<NUM_LIT:3>, <NUM_LIT:4>]:<EOL><INDENT>pass<EOL><DEDENT>if not someint == bool_var == <NUM_LIT:2>:<EOL><INDENT>pass<EOL><DEDENT>if not <NUM_LIT:2> <= someint < <NUM_LIT:3> < <NUM_LIT:4>:<EOL><INDENT>pass<EOL><DEDENT>if not set('<STR_LIT:bar>') <= set('<STR_LIT>'):<EOL><INDENT>pass<EOL><DEDENT>if not set(something) <= <NUM_LIT:3>:<EOL><INDENT>pass<EOL><DEDENT>if not frozenset(something) <= <NUM_LIT:3>:<EOL><INDENT>pass<EOL><DEDENT>


args0 = <NUM_LIT:0><EOL>args1 = args0 * <NUM_LIT:1><EOL>args2 = args1 * <NUM_LIT:2><EOL>args3 = args2 * <NUM_LIT:3><EOL>args4 = args3 * <NUM_LIT:4><EOL>args5 = args4 * <NUM_LIT:5><EOL>args6 = args5 * <NUM_LIT:6><EOL>args7 = args6 * <NUM_LIT:7><EOL>args8 = args7 * <NUM_LIT:8><EOL>args9 = args8 * <NUM_LIT:9><EOL>args10 = args9 * <NUM_LIT:10><EOL>args11 = args10 * <NUM_LIT:11><EOL>args12 = args11 * <NUM_LIT:12><EOL>args13 = args12 * <NUM_LIT><EOL>args14 = args13 * <NUM_LIT><EOL>args15 = args14 * <NUM_LIT:15><EOL>return args15<EOL>

pylint will complains about too many local variables


def too_many_arguments_function(arga, argu, argi, arge, argt, args):

arga = argu<EOL>arga += argi<EOL>arga += arge<EOL>arga += argt<EOL>arga += args<EOL>return arga<EOL>

pylint will complains about too many arguments.


def ignored_arguments_function(arga, argu, argi,<EOL>_arge=<NUM_LIT:0>, _argt=<NUM_LIT:1>, _args=None):

arg0 = <NUM_LIT:0><EOL>arg1 = arg0 * <NUM_LIT:1> + arga<EOL>arg2 = arg1 * <NUM_LIT:2> + argu<EOL>arg3 = arg2 * <NUM_LIT:3> + argi<EOL>arg4 = arg3 * <NUM_LIT:4> + _arge<EOL>arg5 = arg4 * <NUM_LIT:5> + _argt<EOL>arg6 = arg5 * <NUM_LIT:6><EOL>arg7 = arg6 * <NUM_LIT:7><EOL>arg8 = arg7 * <NUM_LIT:8><EOL>arg9 = arg8 * <NUM_LIT:9><EOL>arg9 += arg0<EOL>if _args:<EOL><INDENT>arg9 += sum(_args)<EOL><DEDENT>return arg9<EOL>

pylint will ignore _arge, _argt, _args.

    Consequently pylint will only coun 13 arguments.


var = range(<NUM_LIT:10>)<EOL>if isinstance(var[<NUM_LIT:1>], (int, float)):<EOL><INDENT>pass<EOL><DEDENT>result = isinstance(var[<NUM_LIT:2>], (int, float))<EOL>if isinstance(var[<NUM_LIT:3>], int) or isinstance(var[<NUM_LIT:3>], float) or isinstance(var[<NUM_LIT:3>], list) and True:  <EOL><INDENT>pass<EOL><DEDENT>result = isinstance(var[<NUM_LIT:4>], int) or isinstance(var[<NUM_LIT:4>], float) or isinstance(var[<NUM_LIT:5>], list) and False  <EOL>result = isinstance(var[<NUM_LIT:5>], int) or True or isinstance(var[<NUM_LIT:5>], float)  <EOL>infered_isinstance = isinstance<EOL>result = infered_isinstance(var[<NUM_LIT:6>], int) or infered_isinstance(var[<NUM_LIT:6>], float) or infered_isinstance(var[<NUM_LIT:6>], list) and False   <EOL>result = isinstance(var[<NUM_LIT:10>], str) or isinstance(var[<NUM_LIT:10>], int) and var[<NUM_LIT:8>] * <NUM_LIT> or isinstance(var[<NUM_LIT:10>], float) and var[<NUM_LIT:5>] * <NUM_LIT> or isinstance(var[<NUM_LIT:10>], list)   <EOL>result = isinstance(var[<NUM_LIT:11>], int) or isinstance(var[<NUM_LIT:11>], int) or isinstance(var[<NUM_LIT:11>], float)   <EOL>result = isinstance(var[<NUM_LIT:20>])<EOL>result = isinstance()<EOL>result = isinstance(var[<NUM_LIT:12>], (int, float)) or isinstance(var[<NUM_LIT:12>], list)  <EOL>result = isinstance(var[<NUM_LIT:5>], int) and var[<NUM_LIT:5>] * <NUM_LIT> or isinstance(var[<NUM_LIT:5>], float) and var[<NUM_LIT:5>] * <NUM_LIT><EOL>result = isinstance(var[<NUM_LIT:7>], int) or not isinstance(var[<NUM_LIT:7>], float)<EOL>result = isinstance(var[<NUM_LIT:6>], int) or isinstance(var[<NUM_LIT:7>], float)<EOL>result = isinstance(var[<NUM_LIT:6>], int) or isinstance(var[<NUM_LIT:7>], int)<EOL>return result<EOL>


try:<EOL><INDENT>return self._repo <EOL><DEDENT>except ValueError:<EOL><INDENT>self._repo = attr<EOL>return attr<EOL><DEDENT>


this method is a real method since it access to self


this method isn' a real method since it doesn't need self


raise NotImplementedError<EOL>

an abstract method, could not be a function


return arg == <NUM_LIT:0><EOL>

a concrete method, could not be a function since it need
        polymorphism benefits


print(self.attr)<EOL>


return <NUM_LIT><EOL>

Don't emit no-self-use for properties.

        They can't be functions and they can be part of an
        API specification.


return meta("<STR_LIT>", (base, ), {})<EOL>

Create a new type that can be used as a metaclass.


def __init__(self, first_argument, second_argument, third_argument):


def __init__(self, one=<NUM_LIT:1>, two=<NUM_LIT:2>):


print(some_arg, some_other_arg)<EOL>


def continue3(<EOL>some_arg,         <EOL>some_other_arg):

print(some_arg, some_other_arg)<EOL>


print(args)<EOL>


pass<EOL>


inner = None<EOL>print(inner)<EOL>


BAD_LOCAL_VAR = <NUM_LIT:1>  <EOL>print(BAD_LOCAL_VAR)<EOL>


return NOT_GOOD<EOL>


print(arg1, arg21, arg22)<EOL>


class EmbeddedClass(object):<EOL><INDENT>"""<STR_LIT>"""<EOL><DEDENT>return EmbeddedClass<EOL>


good_variable_name = <NUM_LIT:1><EOL>return good_variable_name + good_arg_name<EOL>


return <NUM_LIT:12><EOL>

Private scope function are cool with long descriptive names


Ignored since the method is in the interface.


@property<EOL><INDENT>def PROPERTY_NAME(self):  <DEDENT>

pass<EOL>


@abc.abstractproperty<EOL><INDENT>def ABSTRACT_PROPERTY_NAME(self):  <DEDENT>

pass<EOL>


@PROPERTY_NAME.setter<EOL><INDENT>def PROPERTY_NAME_SETTER(self):  <DEDENT>

pass<EOL>


try:<EOL><INDENT>raise BBBException("<STR_LIT>")<EOL><DEDENT>except BBBException:<EOL><INDENT>raise<EOL><DEDENT>except AAAException:<EOL><INDENT>raise BBBException("<STR_LIT>")<EOL><DEDENT>


try:<EOL><INDENT>raise BBBException("<STR_LIT>")<EOL><DEDENT>except AAAException:<EOL><INDENT>raise BBBException("<STR_LIT>")<EOL><DEDENT>except:  <EOL><INDENT>raise<EOL><DEDENT>


if <NUM_LIT:1>:<EOL><INDENT>pass<EOL><DEDENT>elif <NUM_LIT:1>:<EOL><INDENT>pass<EOL><DEDENT>elif <NUM_LIT:1>:<EOL><INDENT>pass<EOL><DEDENT>elif <NUM_LIT:1>:<EOL><INDENT>pass<EOL><DEDENT>elif <NUM_LIT:1>:<EOL><INDENT>pass<EOL><DEDENT>elif <NUM_LIT:1>:<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>pass<EOL><DEDENT>finally:<EOL><INDENT>pass<EOL><DEDENT>if <NUM_LIT:2>:<EOL><INDENT>pass<EOL><DEDENT>while True:<EOL><INDENT>pass<EOL><DEDENT>if <NUM_LIT:1>:<EOL><INDENT>pass<EOL><DEDENT>elif <NUM_LIT:2>:<EOL><INDENT>pass<EOL><DEDENT>elif <NUM_LIT:3>:<EOL><INDENT>pass<EOL><DEDENT>


Too many branches only if we take
    into consideration the nested functions.


return self.attr<EOL>


self.attr = value<EOL>


self.correct = <NUM_LIT:1><EOL>


BadClass()<EOL>


return sorted([(isinstance(c.node, astroid.ClassDef), c.title) for c in classes])<EOL>


result = []<EOL>for rel_type, rels in relations.items():<EOL><INDENT>for rel in rels:<EOL><INDENT>result.append((rel_type, rel.from_object.title, rel.to_object.title))<EOL><DEDENT><DEDENT>result.sort()<EOL>return result<EOL>

extract relation indices from a relation list


messages = collections.Counter()<EOL>for i, line in enumerate(stream):<EOL><INDENT>match = _EXPECTED_RE.search(line)<EOL>if match is None:<EOL><INDENT>continue<EOL><DEDENT>line = match.group('<STR_LIT>')<EOL>if line is None:<EOL><INDENT>line = i + <NUM_LIT:1><EOL><DEDENT>elif line.startswith('<STR_LIT:+>') or line.startswith('<STR_LIT:->'):<EOL><INDENT>line = i + <NUM_LIT:1> + int(line)<EOL><DEDENT>else:<EOL><INDENT>line = int(line)<EOL><DEDENT>version = match.group('<STR_LIT:version>')<EOL>op = match.group('<STR_LIT>')<EOL>if version:<EOL><INDENT>required = parse_python_version(version)<EOL>if not _OPERATORS[op](sys.version_info, required):<EOL><INDENT>continue<EOL><DEDENT><DEDENT>for msg_id in match.group('<STR_LIT>').split('<STR_LIT:U+002C>'):<EOL><INDENT>messages[line, msg_id.strip()] += <NUM_LIT:1><EOL><DEDENT><DEDENT>return messages<EOL>

Parses a file and get expected messages.

    :param stream: File-like input stream.
    :returns: A dict mapping line,msg-symbol tuples to the count on this line.


missing = left_op.copy()<EOL>missing.subtract(right_op)<EOL>unexpected = {}<EOL>for key, value in list(six.iteritems(missing)):<EOL><INDENT>if value <= <NUM_LIT:0>:<EOL><INDENT>missing.pop(key)<EOL>if value < <NUM_LIT:0>:<EOL><INDENT>unexpected[key] = -value<EOL><DEDENT><DEDENT><DEDENT>return missing, unexpected<EOL>

Takes two multisets and compares them.

    A multiset is a dict with the cardinality of the key as the value.

    :param left_op: The expected entries.
    :param right_op: Actual entries.

    :returns: The two multisets of missing and unexpected messages.


return re.sub(<EOL>"<STR_LIT>", "<STR_LIT>", output.replace("<STR_LIT:\\>", "<STR_LIT:/>"), flags=re.MULTILINE<EOL>)<EOL>

Remove version-specific tox parent directories from paths.


print(yoo)<EOL>


print('<STR_LIT>', self)<EOL>


print("<STR_LIT>" % {'<STR_LIT>': <NUM_LIT:1>, '<STR_LIT>': <NUM_LIT:2>}) <EOL>print("<STR_LIT:%s>" % (PARG_1, PARG_2)) <EOL>print("<STR_LIT>" % {'<STR_LIT>': <NUM_LIT:1>, '<STR_LIT>': <NUM_LIT:2>}) <EOL>print("<STR_LIT>" % {'<STR_LIT>': <NUM_LIT:1>}) <EOL>print("<STR_LIT>" % {'<STR_LIT>': <NUM_LIT:1>, '<STR_LIT>':<NUM_LIT:2>, '<STR_LIT>':<NUM_LIT:3>}) <EOL>print("<STR_LIT>" % {'<STR_LIT>': <NUM_LIT:1>, <NUM_LIT:2>:<NUM_LIT:3>}) <EOL>print("<STR_LIT>" % (<NUM_LIT:2>, <NUM_LIT:3>)) <EOL>print("<STR_LIT>" % [<NUM_LIT:2>, <NUM_LIT:3>]) <EOL>print("<STR_LIT>" % PARG_1)<EOL>print("<STR_LIT>" % PARG_2)<EOL>print("<STR_LIT>" % <NUM_LIT:1>)<EOL>


print(self)<EOL>


@classmethod<EOL><INDENT>def selected(cls, *args, **kwargs):<DEDENT>

return cls<EOL>

called by the registry when the vobject has been selected.


def using_inner_function(self, etype, size=<NUM_LIT:1>):

rset = AAAA([('<STR_LIT:A>',)]*size, '<STR_LIT>' % etype,<EOL>description=[(etype,)]*size)<EOL>def inner(row, col=<NUM_LIT:0>, etype=etype, req=self, rset=rset):<EOL><INDENT>"""<STR_LIT>"""<EOL>return req.vreg.etype_class(etype)(req, rset, row, col)<EOL><DEDENT>rset.get_entity = inner<EOL>

return a fake result set for a particular entity type


self.spam = <NUM_LIT:1><EOL>

Constructor with an extra parameter. Should raise a warning


yield <NUM_LIT:1><EOL>return<EOL>


print(self, sys)<EOL>


return self, truc<EOL>


print(self, '<STR_LIT>')<EOL>


def __init__(self, name, mode="<STR_LIT:r>", buffering=-<NUM_LIT:1>, verbose=False):

self.was_modified = False<EOL>self.verbose = verbose<EOL>super(File, self).__init__(name, mode, buffering)<EOL>if self.verbose:<EOL><INDENT>print("<STR_LIT>" % (self.name,<EOL>self.mode))<EOL><DEDENT>


super(File, self).write(a_string)<EOL>self.was_modified = True<EOL>


super(File, self).writelines(sequence)<EOL>self.was_modified = True<EOL>

Write a sequence of strings to the file.


if self.verbose:<EOL><INDENT>print("<STR_LIT>" % self.name)<EOL><DEDENT>super(File, self).close()<EOL>self.was_modified = False<EOL>


ggg = lambda: xxx<EOL>xxx = <NUM_LIT:1><EOL>print(ggg())<EOL>


import os as ass<EOL>ass.remove(yooo)<EOL>import re<EOL>re.compile('<STR_LIT>')<EOL>


return log10(<NUM_LIT:2>)<EOL>


from . import w0401_cycle  <EOL>if w0401_cycle:<EOL><INDENT>print(w0401_cycle)<EOL><DEDENT>

Test disabling of cyclic import check inside a function


global __file__<EOL>__file__ = '<STR_LIT>'<EOL>


try:<EOL><INDENT>{}["<STR_LIT:a>"]<EOL><DEDENT>except KeyError as some_function: <EOL><INDENT>pass<EOL><DEDENT>


@ident(ident)<EOL><INDENT>def method(self, val=ident(<NUM_LIT:7>), func=ident):<DEDENT>

print(self)<EOL>return func(val)<EOL>


<EOL>var = <NUM_LIT:0><EOL>


def fetch_order(cls, attr, var):<EOL><INDENT>"""<STR_LIT>"""<EOL>if attr == mainattr:<EOL><INDENT>return var<EOL><DEDENT>return None<EOL><DEDENT>fetch_order = classmethod(fetch_order)<EOL>return fetch_order<EOL>


return self._thing<EOL>


self._thing = value<EOL>


print('<STR_LIT>')<EOL>return None<EOL>


return<EOL>

Function returning None from bare return statement.


print('<STR_LIT>')<EOL>if <NUM_LIT:2> or <NUM_LIT:3>:<EOL><INDENT>return None<EOL><DEDENT>return <NUM_LIT:3><EOL>

function returning none and something else


yield <NUM_LIT:2><EOL>


raise NotImplementedError<EOL>

use to return something in concrete implementation


var = self.abstract_method()<EOL>print(var)<EOL>


return with_<EOL>


self.var[<NUM_LIT:1>] = '<STR_LIT>'<EOL>self.base_var[<NUM_LIT:1>] = '<STR_LIT>'<EOL>return self.base_var, self.var<EOL>

Checks that base_var is not seen as defined outsite '__init__'


yield <NUM_LIT><EOL>xxxx = yield <NUM_LIT><EOL>print(xxxx)<EOL>


for val in seq:<EOL><INDENT>pass<EOL><DEDENT>for val in seq:<EOL><INDENT>yield val<EOL><DEDENT>


xxxx = <NUM_LIT:12><EOL>yield xxxx<EOL>


pass<EOL>


self.e1101 = <NUM_LIT:1><EOL>


BaseClass.__init__(self)<EOL>self.e1101 += <NUM_LIT:1><EOL>


self.e1101 += <NUM_LIT:1><EOL>


BaseClass.__init__(self)<EOL>self.e1101 = self.e1101 + <NUM_LIT:1><EOL>


def __init__(self, host=None, port=<NUM_LIT:0>):

telnetlib.Telnet.__init__(self, host, port)<EOL>

Constructor.
When called without arguments, create an unconnected instance.
With a hostname argument, it connects the instance; a port
number is optional.
Parameter:
- host: IP address of the host
- port: Port number


def readUntilArray(self, matches, _=None):

self.process_rawq()<EOL>maxLength = <NUM_LIT:0><EOL>for match in matches:<EOL><INDENT>if len(match) > maxLength:<EOL><INDENT>maxLength = len(match)<EOL><DEDENT><DEDENT>

Read until a given string is encountered or until timeout.
...


<EOL>if self._var:<EOL><INDENT>print("<STR_LIT:True>")<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT:False>")<EOL><DEDENT>self._var = True<EOL>if self.dougloup_papa:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>self.dougloup_papa = True<EOL>if self.dougloup_moi:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>self.dougloup_moi = True<EOL>


if self.attr:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>self.attr = <NUM_LIT:10><EOL>


self.attr = <NUM_LIT:4><EOL>


print(self)<EOL>


if True:<EOL><INDENT>return <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>yield <NUM_LIT:2><EOL><DEDENT>


if True:<EOL><INDENT>yield <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:2><EOL><DEDENT>


cls._protected = +val<EOL>


A3123._protected += val<EOL>


<EOL>logging.info(<NUM_LIT:0>, '<STR_LIT>') <EOL>logging.info('<STR_LIT>', '<STR_LIT>') <EOL>logging.info('<STR_LIT>', '<STR_LIT>') <EOL>logging.info('<STR_LIT>', '<STR_LIT>') <EOL>logging.info('<STR_LIT>', '<STR_LIT>', '<STR_LIT>') <EOL>logging.info('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>') <EOL>logging.info(<NUM_LIT:1>)<EOL>logging.info(True)<EOL>logging.info('<STR_LIT>')<EOL>logging.info('<STR_LIT>')<EOL>logging.info('<STR_LIT:%s>', '<STR_LIT>')<EOL>logging.info('<STR_LIT>', '<STR_LIT>')<EOL>logging.info('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>

Test string format in logging statements.


value = <NUM_LIT:9><EOL>for _ in range(<NUM_LIT:7>):<EOL><INDENT>print(value)<EOL><DEDENT>

Clobbers a dummy name from the outer scope.


print(func_w0401)<EOL>unic = u"<STR_LIT>"<EOL>low = unic.looower<EOL>return low<EOL>


import os<EOL>print(os)<EOL>


import sys<EOL>del sys<EOL>


aaaa = <NUM_LIT:1><EOL>index = -<NUM_LIT:1><EOL>for match in matches:<EOL><INDENT>index += <NUM_LIT:1><EOL>print(match)<EOL><DEDENT>


branches = <NUM_LIT:1><EOL>if node.orelse and len(node.orelse) > <NUM_LIT:1>:<EOL><INDENT>branches += <NUM_LIT:1><EOL><DEDENT>self.inc_branch(branches)<EOL>self.stmts += branches<EOL>


return {x: lambda: x for x in range(<NUM_LIT:10>)}<EOL>


self.__class__ = new_class<EOL>


return self.topic + <NUM_LIT><EOL>


def _astroid_wrapper(func, modname):<EOL><INDENT>return func(modname)<EOL><DEDENT>return project_from_files([module], _astroid_wrapper, project_name=name)<EOL>

return an astroid project representation


<EOL>print(self._test+ "<STR_LIT:foo>")<EOL>


<EOL>print(self.bla) <EOL>print(self.blop)<EOL>


<EOL>print(self.bla)<EOL>print(self.blop)<EOL>print(self.blip)<EOL>


<EOL>print(self.bla)<EOL>if self.blop:<EOL><INDENT>print(self.blip)<EOL><DEDENT>else:<EOL><INDENT>print(self.blip)<EOL><DEDENT>print(self.blip)<EOL>


<EOL>print(self.bla)<EOL>try:<EOL><INDENT>print(self.blip)<EOL><DEDENT>except UndefinedName: <EOL><INDENT>print(self.blip)<EOL><DEDENT>print(self.blip)<EOL>


if self.blop: <EOL><INDENT>print(self.blip)<EOL><DEDENT>else:<EOL><INDENT>print(self.blip)<EOL><DEDENT>print(self.blip)<EOL>


<EOL>print(self.blip)<EOL>print(self.bla)<EOL>print(self.blop)<EOL>


eris = <NUM_LIT:5><EOL>if eris: <EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>print(self.bla)<EOL>print(self.blu)<EOL>print(self.blip)<EOL>

test re-enabling right after a block with whitespace


<EOL>print(self.bla)<EOL>print(self.blu)<EOL>


def too_complex_but_thats_ok(self, attr1, attr2):

<EOL>try:<EOL><INDENT>attr3 = attr1+attr2<EOL><DEDENT>except ValueError:<EOL><INDENT>attr3 = None<EOL><DEDENT>except:<EOL><INDENT>return '<STR_LIT>', self<EOL><DEDENT>if attr1:<EOL><INDENT>for i in attr1:<EOL><INDENT>if attr2:<EOL><INDENT>return i<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT>elif attr2:<EOL><INDENT>for i in attr2:<EOL><INDENT>if attr2:<EOL><INDENT>return i<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for i in range(<NUM_LIT:15>):<EOL><INDENT>if attr3:<EOL><INDENT>return i<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT>return None<EOL>

THIS Method has too much branches and returns but i don't care


for body_item in node.body:<EOL><INDENT>if (isinstance(body_item, astroid.FunctionDef)<EOL>and hasattr(body_item, '<STR_LIT:name>')):<EOL><INDENT>self.checker.visit_functiondef(body_item)<EOL><DEDENT><DEDENT>

Visit all methods of a class node

        :param node: class node
        :type node: :class:`astroid.scoped_nodes.Class`


pass<EOL>


k = n + <NUM_LIT:4><EOL>s = k + n<EOL>return s<EOL>


if n > <NUM_LIT:3>:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>elif n > <NUM_LIT:4>:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>


for i in range(<NUM_LIT:10>):<EOL><INDENT>print(i)<EOL><DEDENT>


for i in mylist:<EOL><INDENT>print(i)<EOL><DEDENT>else:<EOL><INDENT>print(None)<EOL><DEDENT>


if n > <NUM_LIT:4>:<EOL><INDENT>return f(n - <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>return n<EOL><DEDENT>


def b():<EOL><INDENT>"""<STR_LIT>"""<EOL>def c():<EOL><INDENT>"""<STR_LIT>"""<EOL>pass<EOL><DEDENT>c()<EOL><DEDENT>b()<EOL>


myint = <NUM_LIT:2><EOL>if myint > <NUM_LIT:5>:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if myint <= <NUM_LIT:5>:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>myint = <NUM_LIT:3><EOL>if myint > <NUM_LIT:2>:<EOL><INDENT>if myint > <NUM_LIT:3>:<EOL><INDENT>pass<EOL><DEDENT>elif myint == <NUM_LIT:3>:<EOL><INDENT>pass<EOL><DEDENT>elif myint < <NUM_LIT:3>:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if myint:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if myint:<EOL><INDENT>pass<EOL><DEDENT>myint = <NUM_LIT:4><EOL><DEDENT><DEDENT><DEDENT>


myint = <NUM_LIT:2><EOL>if myint == <NUM_LIT:5>:<EOL><INDENT>return myint<EOL><DEDENT>elif myint == <NUM_LIT:6>:<EOL><INDENT>return myint<EOL><DEDENT>elif myint == <NUM_LIT:7>:<EOL><INDENT>return myint<EOL><DEDENT>elif myint == <NUM_LIT:8>:<EOL><INDENT>return myint<EOL><DEDENT>elif myint == <NUM_LIT:9>:<EOL><INDENT>return myint<EOL><DEDENT>elif myint == <NUM_LIT:10>:<EOL><INDENT>if myint == <NUM_LIT:8>:<EOL><INDENT>while True:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>elif myint == <NUM_LIT:8>:<EOL><INDENT>with myint:<EOL><INDENT>return <NUM_LIT:8><EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if myint == <NUM_LIT:2>:<EOL><INDENT>return myint<EOL><DEDENT>return myint<EOL><DEDENT>return myint<EOL>


if not param1:<EOL><INDENT>pass<EOL><DEDENT>pass<EOL>if param1:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>pass<EOL>if param1:<EOL><INDENT>pass<EOL><DEDENT>if param1:<EOL><INDENT>pass<EOL><DEDENT>if param1:<EOL><INDENT>pass<EOL><DEDENT>if param1:<EOL><INDENT>pass<EOL><DEDENT>if param1:<EOL><INDENT>pass<EOL><DEDENT>if param1:<EOL><INDENT>pass<EOL><DEDENT>if param1:<EOL><INDENT>for value in range(<NUM_LIT:5>):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>pass<EOL>for count in range(<NUM_LIT:6>):<EOL><INDENT>with open('<STR_LIT>') as fp:<EOL><INDENT>count += <NUM_LIT:1><EOL><DEDENT>pass<EOL><DEDENT>pass<EOL>try:<EOL><INDENT>pass<EOL>if not param1:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>if param1:<EOL><INDENT>raise BaseException('<STR_LIT>')<EOL><DEDENT>with open('<STR_LIT>') as fp2:<EOL><INDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>finally:<EOL><INDENT>if param1 is not None:<EOL><INDENT>pass<EOL><DEDENT>for count2 in range(<NUM_LIT:8>):<EOL><INDENT>try:<EOL><INDENT>pass<EOL><DEDENT>except BaseException('<STR_LIT>'):<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>return param1<EOL>


return messages<EOL>


return "<STR_LIT>" % (ex.file, "<STR_LIT:U+002CU+0020>".join(ex.args))<EOL>

function used to replace default __str__ method of exception instances


try:<EOL><INDENT>import coverage.tracer as _<EOL>return False<EOL><DEDENT>except ImportError:<EOL><INDENT>_ = None<EOL>return True<EOL><DEDENT>

Coverage module has C-extension, which we can reuse for test


tmp = tempfile.mkdtemp()<EOL>current_dir = getcwd()<EOL>chdir(tmp)<EOL>abs_tmp = abspath("<STR_LIT:.>")<EOL>try:<EOL><INDENT>yield abs_tmp<EOL><DEDENT>finally:<EOL><INDENT>chdir(current_dir)<EOL>rmtree(abs_tmp)<EOL><DEDENT>

Create a temp directory and change the current location to it.

    This is supposed to be used with a *with* statement.


dirs, files = set(), set()<EOL>for path in paths:<EOL><INDENT>path = join(chroot, path)<EOL>filename = basename(path)<EOL>if filename == "<STR_LIT>":<EOL><INDENT>dirs.add(path)<EOL><DEDENT>else:<EOL><INDENT>dirs.add(dirname(path))<EOL>files.add(path)<EOL><DEDENT><DEDENT>for dirpath in dirs:<EOL><INDENT>if not isdir(dirpath):<EOL><INDENT>os.makedirs(dirpath)<EOL><DEDENT><DEDENT>for filepath in files:<EOL><INDENT>open(filepath, "<STR_LIT:w>").close()<EOL><DEDENT>

Creates directories and files found in <path>.

    :param paths: list of relative paths to files or directories
    :param chroot: the root directory in which paths will be created

    >>> from os.path import isdir, isfile
    >>> isdir('/tmp/a')
    False
    >>> create_files(['a/b/foo.py', 'a/b/c/', 'a/b/c/d/e.py'], '/tmp')
    >>> isdir('/tmp/a')
    True
    >>> isdir('/tmp/a/b/c')
    True
    >>> isfile('/tmp/a/b/c/d/e.py')
    True
    >>> isfile('/tmp/a/b/foo.py')
    True


return self.__value<EOL>


def collect_block_lines(self, msgs_store, module_node):

for msg, lines in self._module_msgs_state.items():<EOL><INDENT>self._raw_module_msgs_state[msg] = lines.copy()<EOL><DEDENT>orig_state = self._module_msgs_state.copy()<EOL>self._module_msgs_state = {}<EOL>self._suppression_mapping = {}<EOL>self._effective_max_line_number = module_node.tolineno<EOL>self._collect_block_lines(msgs_store, module_node, orig_state)<EOL>

Walk the AST to collect block level options line numbers.


def _collect_block_lines(self, msgs_store, node, msg_state):

for child in node.get_children():<EOL><INDENT>self._collect_block_lines(msgs_store, child, msg_state)<EOL><DEDENT>first = node.fromlineno<EOL>last = node.tolineno<EOL>if (<EOL>isinstance(node, (nodes.Module, nodes.ClassDef, nodes.FunctionDef))<EOL>and node.body<EOL>):<EOL><INDENT>firstchildlineno = node.body[<NUM_LIT:0>].fromlineno<EOL><DEDENT>else:<EOL><INDENT>firstchildlineno = last<EOL><DEDENT>for msgid, lines in msg_state.items():<EOL><INDENT>for lineno, state in list(lines.items()):<EOL><INDENT>original_lineno = lineno<EOL>if first > lineno or last < lineno:<EOL><INDENT>continue<EOL><DEDENT>message_definitions = msgs_store.get_message_definitions(msgid)<EOL>for message_definition in message_definitions:<EOL><INDENT>if message_definition.scope == WarningScope.NODE:<EOL><INDENT>if lineno > firstchildlineno:<EOL><INDENT>state = True<EOL><DEDENT>first_, last_ = node.block_range(lineno)<EOL><DEDENT>else:<EOL><INDENT>first_ = lineno<EOL>last_ = last<EOL><DEDENT><DEDENT>for line in range(first_, last_ + <NUM_LIT:1>):<EOL><INDENT>if line in self._module_msgs_state.get(msgid, ()):<EOL><INDENT>continue<EOL><DEDENT>if line in lines:  <EOL><INDENT>state = lines[line]<EOL>original_lineno = line<EOL><DEDENT>if not state:<EOL><INDENT>self._suppression_mapping[(msgid, line)] = original_lineno<EOL><DEDENT>try:<EOL><INDENT>self._module_msgs_state[msgid][line] = state<EOL><DEDENT>except KeyError:<EOL><INDENT>self._module_msgs_state[msgid] = {line: state}<EOL><DEDENT><DEDENT>del lines[lineno]<EOL><DEDENT><DEDENT>

Recursively walk (depth first) AST to collect block level options
        line numbers.


def set_msg_status(self, msg, line, status):

assert line > <NUM_LIT:0><EOL>try:<EOL><INDENT>self._module_msgs_state[msg.msgid][line] = status<EOL><DEDENT>except KeyError:<EOL><INDENT>self._module_msgs_state[msg.msgid] = {line: status}<EOL><DEDENT>

Set status (enabled/disable) for a given message at a given line


def handle_ignored_message(<EOL>self, state_scope, msgid, line, node, args, confidence<EOL>):

if state_scope == MSG_STATE_SCOPE_MODULE:<EOL><INDENT>try:<EOL><INDENT>orig_line = self._suppression_mapping[(msgid, line)]<EOL>self._ignored_msgs[(msgid, orig_line)].add(line)<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>

Report an ignored message.

        state_scope is either MSG_STATE_SCOPE_MODULE or MSG_STATE_SCOPE_CONFIG,
        depending on whether the message was disabled locally in the module,
        or globally. The other arguments are the same as for add_message.


<EOL>vcids = set()<EOL>lcids = set()<EOL>visits = self.visit_events<EOL>leaves = self.leave_events<EOL>for member in dir(checker):<EOL><INDENT>cid = member[<NUM_LIT:6>:]<EOL>if cid == "<STR_LIT:default>":<EOL><INDENT>continue<EOL><DEDENT>if member.startswith("<STR_LIT>"):<EOL><INDENT>v_meth = getattr(checker, member)<EOL>if self._is_method_enabled(v_meth):<EOL><INDENT>visits[cid].append(v_meth)<EOL>vcids.add(cid)<EOL><DEDENT><DEDENT>elif member.startswith("<STR_LIT>"):<EOL><INDENT>l_meth = getattr(checker, member)<EOL>if self._is_method_enabled(l_meth):<EOL><INDENT>leaves[cid].append(l_meth)<EOL>lcids.add(cid)<EOL><DEDENT><DEDENT><DEDENT>visit_default = getattr(checker, "<STR_LIT>", None)<EOL>if visit_default:<EOL><INDENT>for cls in nodes.ALL_NODE_CLASSES:<EOL><INDENT>cid = cls.__name__.lower()<EOL>if cid not in vcids:<EOL><INDENT>visits[cid].append(visit_default)<EOL><DEDENT><DEDENT><DEDENT>

walk to the checker's dir and collect visit and leave methods


cid = astroid.__class__.__name__.lower()<EOL>visit_events = self.visit_events.get(cid, ())<EOL>leave_events = self.leave_events.get(cid, ())<EOL>if astroid.is_statement:<EOL><INDENT>self.nbstatements += <NUM_LIT:1><EOL><DEDENT>for cb in visit_events or ():<EOL><INDENT>cb(astroid)<EOL><DEDENT>for child in astroid.get_children():<EOL><INDENT>self.walk(child)<EOL><DEDENT>for cb in leave_events or ():<EOL><INDENT>cb(astroid)<EOL><DEDENT>

call visit events of astroid checkers for the given node, recurse on
        its children, then leave events.


def normalize_text(text, line_len=<NUM_LIT>, indent="<STR_LIT>"):

return "<STR_LIT:\n>".join(<EOL>textwrap.wrap(<EOL>text, width=line_len, initial_indent=indent, subsequent_indent=indent<EOL>)<EOL>)<EOL>


frame = node.frame()<EOL>module, obj = "<STR_LIT>", []<EOL>while frame:<EOL><INDENT>if isinstance(frame, Module):<EOL><INDENT>module = frame.name<EOL><DEDENT>else:<EOL><INDENT>obj.append(getattr(frame, "<STR_LIT:name>", "<STR_LIT>"))<EOL><DEDENT>try:<EOL><INDENT>frame = frame.parent.frame()<EOL><DEDENT>except AttributeError:<EOL><INDENT>frame = None<EOL><DEDENT><DEDENT>obj.reverse()<EOL>return module, "<STR_LIT:.>".join(obj)<EOL>

return the module name and the frame id in the module


def safe_decode(line, encoding, *args, **kwargs):

try:<EOL><INDENT>return line.decode(encoding or sys.getdefaultencoding(), *args, **kwargs)<EOL><DEDENT>except LookupError:<EOL><INDENT>return line.decode(sys.getdefaultencoding(), *args, **kwargs)<EOL><DEDENT>

return decoded line from encoding or decode with default encoding


for file_pattern in black_list_re:<EOL><INDENT>if file_pattern.match(base_name):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>return False<EOL>

Determines if the basename is matched in a regex blacklist

    :param str base_name: The basename of the file
    :param list black_list_re: A collection of regex patterns to match against.
        Successful matches are blacklisted.

    :returns: `True` if the basename is blacklisted, `False` otherwise.
    :rtype: bool


def expand_modules(files_or_modules, black_list, black_list_re):

result = []<EOL>errors = []<EOL>for something in files_or_modules:<EOL><INDENT>if basename(something) in black_list:<EOL><INDENT>continue<EOL><DEDENT>if _basename_in_blacklist_re(basename(something), black_list_re):<EOL><INDENT>continue<EOL><DEDENT>if exists(something):<EOL><INDENT>try:<EOL><INDENT>modname = "<STR_LIT:.>".join(modutils.modpath_from_file(something))<EOL><DEDENT>except ImportError:<EOL><INDENT>modname = splitext(basename(something))[<NUM_LIT:0>]<EOL><DEDENT>if isdir(something):<EOL><INDENT>filepath = join(something, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>filepath = something<EOL><DEDENT><DEDENT>else:<EOL><INDENT>modname = something<EOL>try:<EOL><INDENT>filepath = modutils.file_from_modpath(modname.split("<STR_LIT:.>"))<EOL>if filepath is None:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>except (ImportError, SyntaxError) as ex:<EOL><INDENT>errors.append({"<STR_LIT:key>": "<STR_LIT>", "<STR_LIT>": modname, "<STR_LIT>": ex})<EOL>continue<EOL><DEDENT><DEDENT>filepath = normpath(filepath)<EOL>modparts = (modname or something).split("<STR_LIT:.>")<EOL>try:<EOL><INDENT>spec = modutils.file_info_from_modpath(modparts, path=sys.path)<EOL><DEDENT>except ImportError:<EOL><INDENT>is_namespace = False<EOL>is_directory = isdir(something)<EOL><DEDENT>else:<EOL><INDENT>is_namespace = modutils.is_namespace(spec)<EOL>is_directory = modutils.is_directory(spec)<EOL><DEDENT>if not is_namespace:<EOL><INDENT>result.append(<EOL>{<EOL>"<STR_LIT:path>": filepath,<EOL>"<STR_LIT:name>": modname,<EOL>"<STR_LIT>": True,<EOL>"<STR_LIT>": filepath,<EOL>"<STR_LIT>": modname,<EOL>}<EOL>)<EOL><DEDENT>has_init = (<EOL>not (modname.endswith("<STR_LIT>") or modname == "<STR_LIT>")<EOL>and basename(filepath) == "<STR_LIT>"<EOL>)<EOL>if has_init or is_namespace or is_directory:<EOL><INDENT>for subfilepath in modutils.get_module_files(<EOL>dirname(filepath), black_list, list_all=is_namespace<EOL>):<EOL><INDENT>if filepath == subfilepath:<EOL><INDENT>continue<EOL><DEDENT>if _basename_in_blacklist_re(basename(subfilepath), black_list_re):<EOL><INDENT>continue<EOL><DEDENT>modpath = _modpath_from_file(subfilepath, is_namespace)<EOL>submodname = "<STR_LIT:.>".join(modpath)<EOL>result.append(<EOL>{<EOL>"<STR_LIT:path>": subfilepath,<EOL>"<STR_LIT:name>": submodname,<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT>": filepath,<EOL>"<STR_LIT>": modname,<EOL>}<EOL>)<EOL><DEDENT><DEDENT><DEDENT>return result, errors<EOL>

take a list of files/modules/packages and return the list of tuple
    (file, module name) which have to be actually checked