code: def mypy_to_pandas(input_lines: Iterator[str]) -> pandas.DataFrame:
      """Reformats mypy output with error codes to a DataFrame.
  
      Adapted from: https://gist.github.com/michaelosthege/24d0703e5f37850c9e5679f69598930a
      """
      current_section = None
      data = {
          "file": [],
          "line": [],
          "type": [],
          "errorcode": [],
          "message": [],
      }
      for line in input_lines:
          line = line.strip()
          elems = line.split(":")
          if len(elems) < 3:
              continue
          try:
              file, lineno, message_type, *_ = elems[0:3]
              message_type = message_type.strip()
              if message_type == "error":
                  current_section = line.split("  [")[-1][:-1]
              message = line.replace(
                  f"{file}:{lineno}: {message_type}: ", ""
              ).replace(f"  [{current_section}]", "")
              data["file"].append(file)
              data["line"].append(lineno)
              data["type"].append(message_type)
              data["errorcode"].append(current_section)
              data["message"].append(message)
          except Exception as ex:
              print(elems)
              print(ex)
      return pandas.DataFrame(data=data).set_index(["file", "line"])
  
file_path: pymc/scripts/run_mypy.py
imports: import argparse
  import importlib
  import os
  import pathlib
  import subprocess
  import sys
  from typing import Iterator
  import pandas
label_desc: Use image node_id 2 for calling a global function with example usage: mypy_to_pandas(input_lines) and returns: pandas