(
    schema: JsonSchema, floatAny: bool, alreadySimplified: bool = False
)
alreadySimplified=true implies that schema has already been simplified
alreadySimplified=true implies that schema has already been simplified
alreadySimplified = true implies that schema has already been simplified
def simplifyNot_(
    schema: JsonSchema, floatAny: bool, alreadySimplified: bool = False
) -> JsonSchema:
    """alreadySimplified=true implies that schema has already been simplified"""
    if "not" in schema:
        # if there is a not/not, we can just skip it
        ret = simplify(schema["not"], floatAny)
        return ret
    elif "anyOf" in schema:
        anys = schema["anyOf"]
        alls = [{"not": s} for s in anys]
        ret = simplifyAll(alls, floatAny)
        return ret
    elif "allOf" in schema:
        alls = schema["allOf"]
        anys = [{"not": s} for s in alls]
        ret = simplifyAny(anys, floatAny)
        return ret
    elif not alreadySimplified:
        s = simplify(schema, floatAny)
        # it is possible that the result of calling simplify
        # resulted in something that we can push 'not' down into
        # so we call ourselves, being careful to avoid an infinite loop.
        return simplifyNot_(s, floatAny, alreadySimplified=True)
    else:
        return {"not": schema}
def simplifyNot_ ( schema : JsonSchema , floatAny : bool , alreadySimplified : bool = False ) -> JsonSchema : if "not" in schema : # if there is a not/not, we can just skip it ret = simplify ( schema [ "not" ] , floatAny ) return ret elif "anyOf" in schema : anys = schema [ "anyOf" ] alls = [ { "not" : s } for s in anys ] ret = simplifyAll ( alls , floatAny ) return ret elif "allOf" in schema : alls = schema [ "allOf" ] anys = [ { "not" : s } for s in alls ] ret = simplifyAny ( anys , floatAny ) return ret elif not alreadySimplified : s = simplify ( schema , floatAny ) # it is possible that the result of calling simplify # resulted in something that we can push 'not' down into # so we call ourselves, being careful to avoid an infinite loop. return simplifyNot_ ( s , floatAny , alreadySimplified = True ) else : return { "not" : schema }