From 9a684c302aee5cbe17d0bb873eaaa02b371621dd Mon Sep 17 00:00:00 2001 From: Torsten Scholak Date: Tue, 2 Jan 2024 17:04:49 +0000 Subject: [PATCH] remove | to be compatible with python 3.8 --- outlines/fsm/json_schema.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/outlines/fsm/json_schema.py b/outlines/fsm/json_schema.py index c7832f311..7701a8049 100644 --- a/outlines/fsm/json_schema.py +++ b/outlines/fsm/json_schema.py @@ -2,7 +2,7 @@ import itertools as it import json import re -from typing import Any, Callable, Type, Union +from typing import Any, Callable, Optional, Type, Union from jsonschema.protocols import Validator from jsonschema.validators import validator_for @@ -103,7 +103,7 @@ def build_regex_from_object( return to_regex(resolver, content) -def to_regex(resolver: None | Resolver, instance: Schema) -> str: +def to_regex(resolver: Optional[Resolver], instance: Schema) -> str: """Translate a JSON Schema instance into a regex that validates the schema. Note @@ -133,7 +133,7 @@ class Path(str): class Regex(str): pass - definitions: dict[str, Path | Regex] = { + definitions: dict[str, Union[Path, Regex]] = { name: Regex(regex) for name, regex in DEFINITIONS.items() }