Skip to content

Commit d28eed6

Browse files
Merge pull request #18 from gambitproject/fix/type-hinting-game
Handle pygambit game type hinting properly
2 parents f3f3470 + 110c7dc commit d28eed6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/draw_tree/core.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
import subprocess
1313
import tempfile
1414
import re
15+
from typing import TYPE_CHECKING
16+
17+
if TYPE_CHECKING:
18+
import pygambit
1519

1620
from pathlib import Path
1721
from typing import List, Optional
@@ -1254,14 +1258,14 @@ def ef_to_tex(ef_file: str, scale_factor: float = 0.8, show_grid: bool = False)
12541258
grid = original_grid
12551259

12561260
def generate_tikz(
1257-
game,
1258-
save_to: Optional[str] = None,
1259-
scale_factor: float = 0.8,
1260-
level_spacing: int = 6,
1261-
sublevel_spacing: int = 2,
1262-
width_spacing: int = 2,
1263-
show_grid: bool = False
1264-
) -> str:
1261+
game: str | "pygambit.gambit.Game",
1262+
save_to: Optional[str] = None,
1263+
scale_factor: float = 0.8,
1264+
level_spacing: int = 6,
1265+
sublevel_spacing: int = 2,
1266+
width_spacing: int = 2,
1267+
show_grid: bool = False,
1268+
) -> str:
12651269
"""
12661270
Generate complete TikZ code from an extensive form (.ef) file.
12671271
@@ -1350,7 +1354,7 @@ def generate_tikz(
13501354

13511355

13521356
def draw_tree(
1353-
game,
1357+
game: str | "pygambit.gambit.Game",
13541358
save_to: Optional[str] = None,
13551359
scale_factor: float = 0.8,
13561360
level_spacing: int = 6,

0 commit comments

Comments
 (0)