def reduce_scopes(expanded_scopes):
    """Reduce expanded scopes to minimal set

    Eliminates overlapping scopes, such as access:services and access:services!service=x
    """
    # unparse_scopes already returns a frozenset
    return unparse_scopes(parse_scopes(expanded_scopes))
Reduce expanded scopes to minimal set

Eliminates overlapping scopes, such as access:services and access:services!service=x
jupyterhub/scopes.py