Skip to content

Commit 1da2873

Browse files
committed
refactor!(run): Simplify params
1 parent 4aa0b52 commit 1da2873

File tree

1 file changed

+45
-78
lines changed

1 file changed

+45
-78
lines changed

libvcs/_internal/run.py

Lines changed: 45 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
Protocol,
2424
Sequence,
2525
Union,
26-
overload,
2726
)
2827

2928
from typing_extensions import TypeAlias
@@ -164,89 +163,38 @@ def __call__(self, output: Union[str, bytes], timestamp: datetime.datetime):
164163
_CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]]
165164
_FILE: TypeAlias = None | int | IO[Any]
166165

167-
# def run(
168-
# args: _CMD,
169-
# bufsize: int = -1,
170-
# executable: StrOrBytesPath | None = None,
171-
# stdin: _FILE | None = None,
172-
# stdout: _FILE | None = None,
173-
# stderr: _FILE | None = None,
174-
# preexec_fn: Callable[[], Any] | None = None,
175-
# close_fds: bool = True,
176-
# shell: bool = False,
177-
# cwd: StrOrBytesPath | None = None,
178-
# env: _ENV | None = None,
179-
# universal_newlines: bool = False,
180-
# startupinfo: Any | None = None,
181-
# creationflags: int = 0,
182-
# restore_signals: bool = True,
183-
# start_new_session: bool = False,
184-
# pass_fds: Any = None,
185-
# *,
186-
# text: bool | None = None,
187-
# encoding: str = "utf-8",
188-
# errors: str | None = None,
189-
# user: str | int | None = None,
190-
# group: str | int | None = None,
191-
# extra_groups: Iterable[str | int] | None = None,
192-
# umask: int = -1,
193-
# pipesize: int = -1,
194-
#
195-
#
196-
# # custom
197-
# log_in_real_time: bool = True,
198-
# check_returncode: bool = True,
199-
# callback: Optional[ProgressCallbackProtocol] = None,
200-
# ):
201-
202-
203-
@overload
204-
def run(
205-
args: _CMD,
206-
bufsize: int = ...,
207-
executable: StrOrBytesPath | None = ...,
208-
stdin: _FILE | None = ...,
209-
stdout: _FILE | None = ...,
210-
stderr: _FILE | None = ...,
211-
preexec_fn: Callable[[], Any] | None = ...,
212-
close_fds: bool = ...,
213-
shell: bool = ...,
214-
cwd: Optional[StrOrBytesPath] = ...,
215-
env: _ENV | None = ...,
216-
universal_newlines: bool = ...,
217-
startupinfo: Any | None = ...,
218-
creationflags: int = ...,
219-
restore_signals: bool = ...,
220-
start_new_session: bool = ...,
221-
pass_fds: Any = ...,
222-
*,
223-
text: bool | None = ...,
224-
encoding: str = "utf-8",
225-
errors: str | None = ...,
226-
user: str | int | None = ...,
227-
group: str | int | None = ...,
228-
extra_groups: Iterable[str | int] | None = ...,
229-
umask: int = ...,
230-
pipesize: int = ...,
231-
# custom
232-
log_in_real_time: bool = True,
233-
check_returncode: bool = True,
234-
callback: Optional[ProgressCallbackProtocol] = None,
235-
):
236-
...
237-
238166

239167
def run(
240-
# args: Union[str, list[str]],
241168
args: _CMD,
169+
bufsize: int = -1,
170+
executable: StrOrBytesPath | None = None,
171+
stdin: _FILE | None = None,
172+
stdout: _FILE | None = None,
173+
stderr: _FILE | None = None,
174+
preexec_fn: Callable[[], Any] | None = None,
175+
close_fds: bool = True,
242176
shell: bool = False,
243-
cwd: Optional[StrOrBytesPath] = None,
177+
cwd: StrOrBytesPath | None = None,
178+
env: _ENV | None = None,
179+
universal_newlines: bool | None = None,
180+
startupinfo: Any | None = None,
181+
creationflags: int = 0,
182+
restore_signals: bool = True,
183+
start_new_session: bool = False,
184+
pass_fds: Any = (),
244185
*,
186+
text: bool | None = None,
187+
encoding: str | None = None,
188+
errors: str | None = None,
189+
user: str | int | None = None,
190+
group: str | int | None = None,
191+
extra_groups: Iterable[str | int] | None = None,
192+
umask: int = -1,
193+
pipesize: int = -1,
245194
# custom
246195
log_in_real_time: bool = True,
247196
check_returncode: bool = True,
248197
callback: Optional[ProgressCallbackProtocol] = None,
249-
**kwargs,
250198
):
251199
"""Run 'cmd' in a shell and return the combined contents of stdout and
252200
stderr (Blocking). Throws an exception if the command exits non-zero.
@@ -285,11 +233,30 @@ def progress_cb(output, timestamp):
285233
"""
286234
proc = subprocess.Popen(
287235
args,
236+
bufsize=bufsize,
237+
executable=executable,
238+
stdin=stdin,
239+
stdout=stdout or subprocess.PIPE,
240+
stderr=stderr or subprocess.PIPE,
241+
preexec_fn=preexec_fn,
242+
close_fds=close_fds,
288243
shell=shell,
289-
stderr=subprocess.PIPE,
290-
stdout=subprocess.PIPE,
291244
cwd=cwd,
292-
**kwargs,
245+
env=env,
246+
universal_newlines=universal_newlines,
247+
startupinfo=startupinfo,
248+
creationflags=creationflags,
249+
restore_signals=restore_signals,
250+
start_new_session=start_new_session,
251+
pass_fds=pass_fds,
252+
text=text,
253+
encoding=encoding,
254+
errors=errors,
255+
user=user,
256+
group=group,
257+
extra_groups=extra_groups,
258+
umask=umask,
259+
pipesize=pipesize,
293260
)
294261

295262
all_output = []

0 commit comments

Comments
 (0)