def get_roles_for(orm_object):
    """Get roles for a given User/Group/etc.

    If User, take into account the user's groups roles as well

    Arguments:
      orm_object: orm.User, orm.Service, orm.Group
          Any role-having entity

    Returns:
      roles (list): list of orm.Role objects assigned to the object.
    """
    if not isinstance(orm_object, orm.Base):
        raise TypeError(f"Only orm objects allowed, got {orm_object}")

    roles = []
    roles.extend(orm_object.roles)

    if isinstance(orm_object, orm.User):
        for group in orm_object.groups:
            roles.extend(group.roles)
    return roles
Get roles for a given User/Group/etc.

If User, take into account the user's groups roles as well

Arguments:
orm_object: orm.User, orm.Service, orm.Group
Any role-having entity

Returns:
roles (list): list of orm.Role objects assigned to the object.
jupyterhub/roles.py