def METHOD_NAME(
    account_name: str | None = None,
    role_name: str | None = None,
    account_role_name: str | None = None,
    only_active: bool = True,
) -> list[User]:
    """Return a list of User objects.
    The role_name parameter allows to filter by role.
    Set only_active to False if you also want non-active users.
    """
    user_query = User.query
    if account_name is not None:
        account = Account.query.filter(Account.name == account_name).one_or_none()
        if not account:
            raise NotFound(f"There is no account named {account_name}!")
        user_query = user_query.filter(User.account == account)
    if only_active:
        user_query = user_query.filter(User.active.is_(True))
    if role_name is not None:
        role = Role.query.filter(Role.name == role_name).one_or_none()
        if role:
            user_query = user_query.filter(User.flexmeasures_roles.contains(role))
    users = user_query.all()
    if account_role_name is not None:
        users = [u for u in users if u.account.has_role(account_role_name)]
    return users