diff --git a/pyproject.toml b/pyproject.toml index 7f91bf75..bec99e91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ dependencies = [ "omegaconf", # reaction_prediction "rdkit", # reaction_prediction, search "tqdm", # reaction_prediction + "typing_extensions ; python_version < '3.8'", # for TypedDict and Protocol imports ] [project.optional-dependencies] diff --git a/syntheseus/interface/bag.py b/syntheseus/interface/bag.py index cacd53c5..563dca9a 100644 --- a/syntheseus/interface/bag.py +++ b/syntheseus/interface/bag.py @@ -1,7 +1,13 @@ +import sys from collections.abc import Collection from typing import Generic, Iterable, Iterator, TypeVar -from typing_extensions import Protocol +# mypy-compatible import recommended here: +# https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-module +if sys.version_info >= (3, 8): + from typing import Protocol +else: + from typing_extensions import Protocol class Comparable(Protocol):