Skip to content

Commit

Permalink
fix: support python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Sep 11, 2024
1 parent 1eb55d3 commit 1b7f0e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
21 changes: 12 additions & 9 deletions g2p/mappings/langs/network_lite.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections import deque
from typing import (
Any,
Dict,
Generic,
Hashable,
Expand All @@ -8,11 +9,12 @@
List,
Set,
Tuple,
TypedDict,
TypeVar,
Union,
)

from typing_extensions import TypedDict

T = TypeVar("T", bound=Hashable)


Expand Down Expand Up @@ -148,20 +150,21 @@ def shortest_path(self, u: T, v: T) -> List[T]:
raise ValueError(f"No path from {u} to {v}")


# NOTE: not generic because that is impossible, unfortunately
NodeDict = TypedDict("NodeDict", {"id": Hashable})
# NOTE: not generic because that seems to be impossible (due to use of
# `id` as a key, we cannot use the class syntax which would allow us
# to inherit from Generic[T]...)
NodeDict = TypedDict("NodeDict", {"id": Any})


# NOTE: not generic because that is not possible before Python 3.11
class NodeLinkDict(TypedDict):
source: Hashable
target: Hashable
class NodeLinkDict(TypedDict, Generic[T]):
source: T
target: T


class NodeLinkDataDict(TypedDict):
class NodeLinkDataDict(TypedDict, Generic[T]):
directed: bool
graph: Dict
links: List[NodeLinkDict]
links: List[NodeLinkDict[T]]
multigraph: bool
nodes: List[NodeDict]

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies = [
"regex",
"text_unidecode",
"tqdm",
"typing_extensions",
]

[project.optional-dependencies]
Expand Down

0 comments on commit 1b7f0e5

Please sign in to comment.