Accept suggestions from new toolchain · rec/sproc@276eb16

Original file line numberDiff line numberDiff line change

@@ -36,9 +36,10 @@

3636

import shlex

3737

import subprocess

3838

import typing as t

39+

from collections.abc import Sequence

3940

from queue import Queue

4041

from threading import Thread

41-

from typing import Callable, List, Mapping, Optional, Sequence, Union

42+

from typing import Optional, Union

4243
4344

__all__ = 'Sub', 'call', 'call_in_thread', 'run', 'log'

4445

@@ -78,7 +79,7 @@ def __init__(self, cmd: Cmd, *, by_lines: bool = True, **kwargs: t.Any) -> None:

7879

self.cmd = cmd

7980

self.by_lines = by_lines

8081

self.kwargs = dict(kwargs, **DEFAULTS)

81-

self._threads: List[Thread] = []

82+

self._threads: list[Thread] = []

8283
8384

shell = kwargs.get('shell', False)

8485

if isinstance(cmd, str):

@@ -186,10 +187,10 @@ def log(

186187

"""

187188

return self.call(lambda x: print(out + x), lambda x: print(err + x))

188189
189-

def join(self, timeout: Optional[int] = None) -> None:

190+

def join(self, timeout: int | None = None) -> None:

190191

"""Join the stream handling threads"""

191-

for t in self._threads:

192-

t.join(timeout)

192+

for th in self._threads:

193+

th.join(timeout)

193194
194195

def kill(self) -> None:

195196

"""Kill the running process, if any"""