docs: def get_principals(
          self, role, anonymous=True, users=True, groups=True, object=None, as_list=True
      ):
          """Return all users which are assigned given role."""
          if not isinstance(role, Role):
              role = Role(role)
          assert role
          assert users or groups
          query = RoleAssignment.query.filter_by(role=role)
  
          if not anonymous:
              query = query.filter(RoleAssignment.anonymous == False)
          if not users:
              query = query.filter(RoleAssignment.user == None)
          elif not groups:
              query = query.filter(RoleAssignment.group == None)
  
          query = query.filter(RoleAssignment.object == object)
          principals = {(ra.user or ra.group) for ra in query.all()}
  
          if object is not None and role in (Creator, Owner):
              p = object.creator if role == Creator else object.owner
              if p:
                  principals.add(p)
  
          if not as_list:
              return principals
  
          return list(principals)