diff --git a/haystack/schema.py b/haystack/schema.py index 40992ac49e..992e136220 100644 --- a/haystack/schema.py +++ b/haystack/schema.py @@ -5,11 +5,6 @@ from typing import Any, Optional, Dict, List, Union -try: - from typing import Literal -except ImportError: - from typing_extensions import Literal # type: ignore - from pathlib import Path from uuid import uuid4 import logging @@ -18,6 +13,12 @@ import ast from dataclasses import asdict +# The Literal type from typing_extension is safer to use as +# the one from typing has different bugs in the different versions. +# For more info see typing_extensions official docs: +# https://typing-extensions.readthedocs.io/en/latest/#Literal +from typing_extensions import Literal + import numpy as np from numpy import ndarray import pandas as pd diff --git a/pyproject.toml b/pyproject.toml index e1bac8b5ea..d627545891 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,10 @@ classifiers = [ dependencies = [ "requests", "pydantic", + # FIXME: typing_extensions 4.6.0 broke Pydantic, so we pin it temporarily + # waiting for the release. For more info see this issue: + # https://github.com/pydantic/pydantic/issues/5821 + "typing_extensions==4.5.0", "transformers[torch]==4.29.1", "protobuf<=3.20.2", # same version they use in transformers[sentencepiece] "pandas", @@ -184,7 +188,6 @@ dev = [ "pre-commit", # Type check "mypy", - "typing_extensions; python_version < '3.8'", # Test "pytest", "pytest-cov",