Skip to content

Commit

Permalink
Correctly specify dependency on typing_extensions (#107)
Browse files Browse the repository at this point in the history
Syntheseus previously depended on typing_extensions without specifying
this in the `pyproject.toml` file, causing a fresh install to fail the
tests. This PR fixes this by:

1. Wrapping the second import of typing_extensions in an if/else block
to only run if python < 3.8 is used (otherwise an import from `typing`
can be used directly). This was already present in the first import of
typing_extensions.
2. Modify pyproject.toml to specify that `typing_extensions` is
required, but _only if python < 3.8_.

---------

Co-authored-by: Austin T <austin.james.tripp[at]gmail.com>
  • Loading branch information
AustinT authored Nov 21, 2024
1 parent 085b92e commit 713ab41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 7 additions & 1 deletion syntheseus/interface/bag.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit 713ab41

Please sign in to comment.