def render(self, only_line=False, colored=False):
source_line = self.location.source_line().rstrip("<STR_LIT:\n>")<EOL>highlight_line = bytearray(re.sub(r"<STR_LIT>", "<STR_LIT:U+0020>", source_line), "<STR_LIT:utf-8>")<EOL>for hilight in self.highlights:<EOL><INDENT>if hilight.line() == self.location.line():<EOL><INDENT>lft, rgt = hilight.column_range()<EOL>highlight_line[lft:rgt] = bytearray("<STR_LIT>", "<STR_LIT:utf-8>") * (rgt - lft)<EOL><DEDENT><DEDENT>lft, rgt = self.location.column_range()<EOL>if rgt == lft: <EOL><INDENT>rgt = lft + <NUM_LIT:1><EOL><DEDENT>highlight_line[lft:rgt] = bytearray("<STR_LIT>", "<STR_LIT:utf-8>") * (rgt - lft)<EOL>if only_line:<EOL><INDENT>location = "<STR_LIT>" % (self.location.source_buffer.name, self.location.line())<EOL><DEDENT>else:<EOL><INDENT>location = str(self.location)<EOL><DEDENT>notes = list(self.notes)<EOL>if self.level != "<STR_LIT>":<EOL><INDENT>expanded_location = self.location.expanded_from<EOL>while expanded_location is not None:<EOL><INDENT>notes.insert(<NUM_LIT:0>, Diagnostic("<STR_LIT>",<EOL>"<STR_LIT>", {},<EOL>self.location.expanded_from))<EOL>expanded_location = expanded_location.expanded_from<EOL><DEDENT><DEDENT>rendered_notes = reduce(list.__add__, [note.render(only_line, colored)<EOL>for note in notes], [])<EOL>if colored:<EOL><INDENT>if self.level in ("<STR_LIT:error>", "<STR_LIT>"):<EOL><INDENT>level_color = <NUM_LIT> <EOL><DEDENT>elif self.level == "<STR_LIT>":<EOL><INDENT>level_color = <NUM_LIT> <EOL><DEDENT>else: <EOL><INDENT>level_color = <NUM_LIT:30> <EOL><DEDENT>return [<EOL>"<STR_LIT>".<EOL>format(location, level_color, self.level, self.message()),<EOL>source_line,<EOL>"<STR_LIT>".format(highlight_line.decode("<STR_LIT:utf-8>"))<EOL>] + rendered_notes<EOL><DEDENT>else:<EOL><INDENT>return [<EOL>"<STR_LIT>".format(location, self.level, self.message()),<EOL>source_line,<EOL>highlight_line.decode("<STR_LIT:utf-8>")<EOL>] + rendered_notes<EOL><DEDENT>
Returns the human-readable location of the diagnostic in the source,
the formatted message, the source line corresponding
to ``location`` and a line emphasizing the problematic
locations in the source line using ASCII art, as a list of lines.
Appends the result of calling :meth:`render` on ``notes``, if any.

For example: ::

    <input>:1:8-9: error: cannot add integer and string
    x + (1 + "a")
         ~ ^ ~~~

:param only_line: (bool) If true, only print line number, not line and column range