Skip to content

Commit e688d29

Browse files
committed
fix typehints and tests
1 parent 20a0a58 commit e688d29

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

structured_tutorials/runners/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def run_shell_command(
7171
command: CommandType,
7272
show_output: bool,
7373
capture_output: bool = False,
74-
stdin: int | io.IO[Any] | None = None,
74+
stdin: int | io.BufferedReader | None = None,
7575
input: bytes | None = None,
76-
) -> CompletedProcess[str]:
76+
) -> CompletedProcess[bytes]:
7777
# Only show output if runner itself is not configured to hide all output
7878
if show_output:
7979
show_output = self.show_command_output

structured_tutorials/runners/local.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def run_commands(self, part: CommandsPartModel) -> None:
8888
if stdin_config.contents:
8989
proc_input = self.render(stdin_config.contents).encode("utf-8")
9090
elif stdin_config.template: # source path, but template=True
91+
assert stdin_config.source is not None
9192
with open(self.tutorial.tutorial_root / stdin_config.source) as stream:
9293
stdin_template = stream.read()
9394
proc_input = self.render(stdin_template).encode("utf-8")
@@ -98,7 +99,7 @@ def run_commands(self, part: CommandsPartModel) -> None:
9899
and command_config.run.stdin.source
99100
and not command_config.run.stdin.template
100101
):
101-
with open(self.tutorial.tutorial_root / stdin_config.source, "rb") as stdin:
102+
with open(self.tutorial.tutorial_root / command_config.run.stdin.source, "rb") as stdin:
102103
proc = self.run_shell_command(
103104
command_config.command,
104105
show_output=command_config.run.show_output,

tests/runners/local/test_command.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def test_command_with_stdin(fp: FakeProcess, runner: LocalTutorialRunner) -> Non
8787
cat_three = fp.register("cat", stdout=b"test: {{ variable }}")
8888
runner.run()
8989

90-
assert cat_one.calls[0].kwargs["stdin"] == -1
91-
assert cat_two.calls[0].kwargs["stdin"] == -1
92-
assert isinstance(cat_three.calls[0].kwargs["stdin"], io.BufferedReader)
90+
assert cat_one.calls[0].kwargs["stdin"] == -1 # type: ignore[index]
91+
assert cat_two.calls[0].kwargs["stdin"] == -1 # type: ignore[index]
92+
assert isinstance(cat_three.calls[0].kwargs["stdin"], io.BufferedReader) # type: ignore[index]
9393

9494

9595
@pytest.mark.tutorial("command-hide-output")

0 commit comments

Comments
 (0)