A compatibility wrapper for listing class attributes.

  This method solves similar Python 2 compatibility issues for `dir` function as
  `GetName` does for `__name__` invocations. See documentation for `GetName` for
  more details.

  Once support for Python 2 is dropped all invocations of this function should
  be replaced with ordinary `dir` calls.

  Args:
    cls: A class object to list the attributes for.

  Returns:
    A list of attribute names as unicode strings.

def ListAttrs(cls):
  """A compatibility wrapper for listing class attributes.

  This method solves similar Python 2 compatibility issues for `dir` function as
  `GetName` does for `__name__` invocations. See documentation for `GetName` for
  more details.

  Once support for Python 2 is dropped all invocations of this function should
  be replaced with ordinary `dir` calls.

  Args:
    cls: A class object to list the attributes for.

  Returns:
    A list of attribute names as unicode strings.
  """
  precondition.AssertType(cls, type)

  if PY2:
    # TODO(user): once https://github.com/google/pytype/issues/127 is fixed,
    # pytype should be able to tell that this line is unreachable in py3.
    return [item.decode("ascii") for item in dir(cls)]  # pytype: disable=attribute-error
  else:
    return dir(cls)