docs: def _get_class_frame_source(class_name):
      # type: (str) -> Optional[str]
      """Return the source code for a class by checking the frame stack.
  
      This is necessary because it is not possible to get the source of a class
      being created by a metaclass directly.
  
      Args:
          class_name: The class to look for on the stack.
  
      Returns:
          The source code for the requested class if the class was found and the
          source was accessible.
      """
      for frame_info in inspect.stack():
          try:
              with open(frame_info[1]) as fp:
                  src = "".join(fp.readlines()[frame_info[2] - 1 :])
          except IOError:
              continue
          if re.search(r"\bclass\b\s+\b{}\b".format(class_name), src):
              reader = six.StringIO(src).readline
              tokens = tokenize.generate_tokens(reader)
              source_tokens = []
              indent_level = 0
              base_indent_level = 0
              has_base_level = False
              for token, value, _, _, _ in tokens:  # type: ignore
                  source_tokens.append((token, value))
                  if token == tokenize.INDENT:
                      indent_level += 1
                  elif token == tokenize.DEDENT:
                      indent_level -= 1
                      if has_base_level and indent_level <= base_indent_level:
                          return (
                              tokenize.untokenize(source_tokens),
                              frame_info[0].f_globals,
                              frame_info[0].f_locals,
                          )
                  elif not has_base_level:
                      has_base_level = True
                      base_indent_level = indent_level
      raise TypeError(
          'Unable to retrieve source for class "{}"'.format(class_name)
      )