Skip to content

Commit 16f17f5

Browse files
committed
Fix up mocker
1 parent bd5e0fe commit 16f17f5

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/py/kaleido/mocker/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ async def _main():
4444
headless=args.headless,
4545
timeout=args.timeout,
4646
) as k:
47-
return await k.write_fig_from_object(
47+
# pyright doesn't understand bool = Literal[True] | Literal[False]
48+
return await k.write_fig_from_object( # type: ignore[reportCallIssue]
4849
_utils.load_figures_from_paths(paths),
4950
stepper=args.stepper,
5051
cancel_on_error=args.fail_fast,

src/py/kaleido/mocker/_utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
from ._args import args
1111

1212
if TYPE_CHECKING:
13-
...
13+
from typing import Generator
14+
15+
from kaleido._utils.fig_tools import LayoutOpts
16+
from kaleido.kaleido import FigureDict
1417

1518
_logger = logistro.getLogger(__name__)
1619

@@ -35,7 +38,7 @@ class Param(TypedDict):
3538

3639

3740
# maybe don't have this do params and figures
38-
def load_figures_from_paths(paths: list[Path]):
41+
def load_figures_from_paths(paths: list[Path]) -> Generator[FigureDict, None]:
3942
# Set json
4043
for path in paths:
4144
if not path.is_file():
@@ -54,7 +57,7 @@ def load_figures_from_paths(paths: list[Path]):
5457
if not args.parameterize
5558
else f"{path.stem!s}-{w!s}x{h!s}@{s!s}.{f!s}"
5659
)
57-
opts = {
60+
opts: LayoutOpts = {
5861
"scale": s,
5962
"width": w,
6063
"height": h,
@@ -65,3 +68,6 @@ def load_figures_from_paths(paths: list[Path]):
6568
"path": str(Path(args.output) / name),
6669
"opts": opts,
6770
}
71+
72+
class FigureDict(TypedDict):
73+
"""The type a fig_dicts returns for `write_fig_from_object`."""

0 commit comments

Comments
 (0)