[New-bugs-announce] [issue30420] Clarify kwarg handing for subprocess convenience APIs
Nick Coghlan
report at bugs.python.org
Sat May 20 23:29:11 EDT 2017
New submission from Nick Coghlan:
As per the discussion in https://github.com/python/cpython/pull/1685, the current nominal signatures of the convenience APIs in subprocess is confusing, as they don't make it clear that all Popen keyword arguments are supported, with only the most common ones being listed in the signature.
Proposed fixes:
* add `cwd` to the list of frequently used arguments, and list it in the nominal signatures for `run()`, `call()`, `check_call()`, and `check_output()`
* append `**popenargs` to the nominal signatures of `run()`, `call()`, and `check_call()`
* append `**runargs` to the nominal signature of `check_output()`
* amend the prose descriptions for these functions accordingly
Background:
The status quo is that while this behaviour is documented, it's documented solely as text in the bodies of the API definitions, using paragraphs like the following:
`run()`: """The arguments shown above are merely the most common ones, described below in Frequently Used Arguments (hence the use of keyword-only notation in the abbreviated signature). The full function signature is largely the same as that of the Popen constructor - apart from timeout, input and check, all the arguments to this function are passed through to that interface."""
`call()`, `check_call()`: """The arguments shown above are merely the most common ones. The full function signature is largely the same as that of the Popen constructor - this function passes all supplied arguments other than timeout directly through to that interface."""
`check_output()`: """The arguments shown above are merely the most common ones. The full function signature is largely the same as that of run() - most arguments are passed directly through to that interface."""
While it's technically anecdotal, we still have pretty decent evidence that this isn't adequate as:
- I worked on the original patch splitting out the "Frequently Used Arguments" section, and initially missed not only that the run() docs had retained that paragraph, but also missed the revised paragraphs in the relocated docs for the older API
- as mentioned in the linked PR, Paul Kehrer had missed that `check_call()` and `check_output()` both supported the Popen `cwd` parameter
The working theory behind adding the appropriately named `**kwargs` parameters to the end of the nominal signatures is that it will give readers a clearer indication that we're *not* explicitly listing all the parameters, and a hint as to which API to go look at to find out more about the unlisted ones.
----------
assignee: docs at python
components: Documentation
messages: 294070
nosy: docs at python, ncoghlan
priority: normal
severity: normal
stage: needs patch
status: open
title: Clarify kwarg handing for subprocess convenience APIs
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30420>
_______________________________________
More information about the New-bugs-announce
mailing list