Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9fb350e

Browse filesBrowse files
committed
refactor!(SubprocessCommand): subprocess.Popen typings
See also: https://github.com/python/typeshed/blob/8b58371/stdlib/subprocess.pyi#L1179-L1355
1 parent e7dbd92 commit 9fb350e
Copy full SHA for 9fb350e

File tree

Expand file treeCollapse file tree

1 file changed

+83
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+83
-2
lines changed

‎libvcs/_internal/subprocess.py

Copy file name to clipboardExpand all lines: libvcs/_internal/subprocess.py
+83-2Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,78 @@ class SubprocessCommand(SkipDefaultFieldsReprMixin):
204204
encoding: Optional[str] = None
205205
errors: Optional[str] = None
206206

207-
def Popen(self, **kwargs) -> subprocess.Popen:
207+
# user, group, extra_groups, umask were added in 3.9
208+
@overload
209+
def Popen(
210+
self,
211+
args: Optional[_CMD] = ...,
212+
universal_newlines: bool = ...,
213+
*,
214+
text: Optional[bool] = ...,
215+
encoding: str,
216+
errors: Optional[str] = ...,
217+
) -> subprocess.Popen[str]:
218+
...
219+
220+
@overload
221+
def Popen(
222+
self,
223+
args: Optional[_CMD] = ...,
224+
universal_newlines: bool = ...,
225+
*,
226+
text: Optional[bool] = ...,
227+
encoding: Optional[str] = ...,
228+
errors: str,
229+
) -> subprocess.Popen[str]:
230+
...
231+
232+
@overload
233+
def Popen(
234+
self,
235+
args: Optional[_CMD] = ...,
236+
*,
237+
universal_newlines: Literal[True],
238+
# where the *real* keyword only args start
239+
text: Optional[bool] = ...,
240+
encoding: Optional[str] = ...,
241+
errors: Optional[str] = ...,
242+
) -> subprocess.Popen[str]:
243+
...
244+
245+
@overload
246+
def Popen(
247+
self,
248+
args: Optional[_CMD] = ...,
249+
universal_newlines: bool = ...,
250+
*,
251+
text: Literal[True],
252+
encoding: Optional[str] = ...,
253+
errors: Optional[str] = ...,
254+
) -> subprocess.Popen[str]:
255+
...
256+
257+
@overload
258+
def Popen(
259+
self,
260+
args: Optional[_CMD] = ...,
261+
universal_newlines: Literal[False] = ...,
262+
*,
263+
text: Literal[None, False] = ...,
264+
encoding: None = ...,
265+
errors: None = ...,
266+
) -> subprocess.Popen[bytes]:
267+
...
268+
269+
def Popen(
270+
self,
271+
args: Optional[_CMD] = None,
272+
universal_newlines: Optional[bool] = None,
273+
*,
274+
text: Optional[bool] = None,
275+
encoding: Optional[str] = None,
276+
errors: Optional[str] = None,
277+
**kwargs,
278+
) -> subprocess.Popen[Any]:
208279
"""Run commands :class:`subprocess.Popen`, optionally overrides via kwargs.
209280
210281
Parameters
@@ -218,7 +289,17 @@ def Popen(self, **kwargs) -> subprocess.Popen:
218289
>>> proc = cmd.Popen(stdout=subprocess.PIPE)
219290
>>> proc.communicate() # doctest: +SKIP
220291
"""
221-
return subprocess.Popen(**dataclasses.replace(self, **kwargs).__dict__)
292+
return subprocess.Popen(
293+
**dataclasses.replace(
294+
self,
295+
args=args or self.args,
296+
encoding=encoding,
297+
errors=errors,
298+
text=text,
299+
universal_newlines=universal_newlines,
300+
**kwargs,
301+
).__dict__,
302+
)
222303

223304
def check_call(self, **kwargs) -> int:
224305
"""Run command :func:`subprocess.check_call`, optionally overrides via kwargs.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.