Skip to content

Commit 557b626

Browse files
authored
Merge pull request #517 from gerlero/typing
Update typing
2 parents cfe2a1f + b8336b1 commit 557b626

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

foamlib/_cases/_run.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
from abc import abstractmethod
99
from contextlib import contextmanager
1010
from pathlib import Path
11-
from typing import IO, TYPE_CHECKING, Any
12-
13-
from rich.progress import Progress
14-
15-
from ._util import SingletonContextManager
11+
from typing import TYPE_CHECKING, Any
1612

1713
if sys.version_info >= (3, 9):
1814
from collections.abc import (
@@ -33,6 +29,13 @@
3329
Sequence,
3430
)
3531

32+
if TYPE_CHECKING:
33+
from io import TextIOBase
34+
35+
from rich.progress import Progress
36+
37+
from ._util import SingletonContextManager
38+
3639
if sys.version_info >= (3, 11):
3740
from typing import Self
3841
else:
@@ -278,7 +281,7 @@ def __cmd_name(cmd: Sequence[str | os.PathLike[str]] | str) -> str:
278281
@contextmanager
279282
def __output(
280283
self, cmd: Sequence[str | os.PathLike[str]] | str, *, log: bool
281-
) -> Generator[tuple[int | IO[str], int | IO[str]], None, None]:
284+
) -> Generator[tuple[int | TextIOBase, int | TextIOBase], None, None]:
282285
if log:
283286
with (self.path / f"log.{self.__cmd_name(cmd)}").open("a") as stdout:
284287
yield stdout, STDOUT

foamlib/_cases/_subprocess.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import subprocess
88
import sys
99
import time
10-
from io import StringIO
10+
from io import StringIO, TextIOBase
1111
from pathlib import Path
1212

1313
if sys.version_info >= (3, 9):
@@ -68,8 +68,8 @@ def run_sync(
6868
*,
6969
case: Path,
7070
check: bool = True,
71-
stdout: int | StringIO = DEVNULL,
72-
stderr: int | StringIO = STDOUT,
71+
stdout: int | TextIOBase = DEVNULL,
72+
stderr: int | TextIOBase = STDOUT,
7373
process_stdout: Callable[[str], None] = lambda _: None,
7474
) -> CompletedProcess[str]:
7575
# Set up log file monitoring
@@ -146,8 +146,8 @@ async def run_async(
146146
*,
147147
case: Path,
148148
check: bool = True,
149-
stdout: int | StringIO = DEVNULL,
150-
stderr: int | StringIO = STDOUT,
149+
stdout: int | TextIOBase = DEVNULL,
150+
stderr: int | TextIOBase = STDOUT,
151151
process_stdout: Callable[[str], None] = lambda _: None,
152152
) -> CompletedProcess[str]:
153153
# Set up log file monitoring

0 commit comments

Comments
 (0)