def _yaml_type_factory(name, base):
  """
  Generates a subclass for the specified *base* class where its constructor
  accepts a filename and line number as the first two arguments.
  """

  class _YamlType(base):

    def __init__(self, filename, lineno, *args, **kwargs):
      super(_YamlType, self).__init__(*args, **kwargs)
      self.filename = filename
      self.lineno = lineno

    def __repr__(self):
      return '{}({})'.format(type(self).__name__, super(_YamlType, self).__repr__())

  _YamlType.__name__ = name
  if hasattr(_YamlType, '__qualname__'):
    _YamlType.__qualname__ = name

  return _YamlType