Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b798ab

Browse files
committed
Issue #24878: Add docstrings to selected namedtuples
1 parent 02aa342 commit 5b798ab

6 files changed

Lines changed: 53 additions & 2 deletions

File tree

Lib/aifc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,14 @@ def _write_float(f, x):
257257
_aifc_params = namedtuple('_aifc_params',
258258
'nchannels sampwidth framerate nframes comptype compname')
259259

260+
_aifc_params.nchannels.__doc__ = 'Number of audio channels (1 for mono, 2 for stereo)'
261+
_aifc_params.sampwidth.__doc__ = 'Ample width in bytes'
262+
_aifc_params.framerate.__doc__ = 'Sampling frequency'
263+
_aifc_params.nframes.__doc__ = 'Number of audio frames'
264+
_aifc_params.comptype.__doc__ = 'Compression type ("NONE" for AIFF files)'
265+
_aifc_params.compname.__doc__ = ("""A human-readable version ofcompression type
266+
('not compressed' for AIFF files)'""")
267+
260268

261269
class Aifc_read:
262270
# Variables used in this class:

Lib/dis.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ def show_code(co, *, file=None):
162162
_Instruction = collections.namedtuple("_Instruction",
163163
"opname opcode arg argval argrepr offset starts_line is_jump_target")
164164

165+
_Instruction.opname.__doc__ = "Human readable name for operation"
166+
_Instruction.opcode.__doc__ = "Numeric code for operation"
167+
_Instruction.arg.__doc__ = "Numeric argument to operation (if any), otherwise None"
168+
_Instruction.argval.__doc__ = "Resolved arg value (if known), otherwise same as arg"
169+
_Instruction.argrepr.__doc__ = "Human readable description of operation argument"
170+
_Instruction.offset.__doc__ = "Start index of operation within bytecode sequence"
171+
_Instruction.starts_line.__doc__ = "Line started by this opcode (if any), otherwise None"
172+
_Instruction.is_jump_target.__doc__ = "True if other code jumps to here, otherwise False"
173+
165174
class Instruction(_Instruction):
166175
"""Details for a bytecode operation
167176

Lib/sched.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ def __le__(s, o): return (s.time, s.priority) <= (o.time, o.priority)
4646
def __gt__(s, o): return (s.time, s.priority) > (o.time, o.priority)
4747
def __ge__(s, o): return (s.time, s.priority) >= (o.time, o.priority)
4848

49+
Event.time.__doc__ = ('''Numeric type compatible with the return value of the
50+
timefunc function passed to the constructor.''')
51+
Event.priority.__doc__ = ('''Events scheduled for the same time will be executed
52+
in the order of their priority.''')
53+
Event.action.__doc__ = ('''Executing the event means executing
54+
action(*argument, **kwargs)''')
55+
Event.argument.__doc__ = ('''argument is a sequence holding the positional
56+
arguments for the action.''')
57+
Event.kwargs.__doc__ = ('''kwargs is a dictionary holding the keyword
58+
arguments for the action.''')
59+
4960
_sentinel = object()
5061

5162
class scheduler:

Lib/selectors.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,17 @@ def _fileobj_to_fd(fileobj):
4343

4444

4545
SelectorKey = namedtuple('SelectorKey', ['fileobj', 'fd', 'events', 'data'])
46-
"""Object used to associate a file object to its backing file descriptor,
47-
selected event mask and attached data."""
4846

47+
SelectorKey.__doc__ = """SelectorKey(fileobj, fd, events, data)
48+
49+
Object used to associate a file object to its backing
50+
file descriptor, selected event mask, and attached data.
51+
"""
52+
SelectorKey.fileobj.__doc__ = 'File object registered.'
53+
SelectorKey.fd.__doc__ = 'Underlying file descriptor.'
54+
SelectorKey.events.__doc__ = 'Events that must be waited for on this file object.'
55+
SelectorKey.data.__doc__ = ('''Optional opaque data associated to this file object.
56+
For example, this could be used to store a per-client session ID.''')
4957

5058
class _SelectorMapping(Mapping):
5159
"""Mapping of file objects to selector keys."""

Lib/shutil.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,9 @@ def unpack_archive(filename, extract_dir=None, format=None):
965965

966966
__all__.append('disk_usage')
967967
_ntuple_diskusage = collections.namedtuple('usage', 'total used free')
968+
_ntuple_diskusage.total.__doc__ = 'Total space in bytes'
969+
_ntuple_diskusage.used.__doc__ = 'Used space in bytes'
970+
_ntuple_diskusage.free.__doc__ = 'Free space in bytes'
968971

969972
def disk_usage(path):
970973
"""Return disk usage statistics about the given path.

Lib/sndhdr.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@
3737
SndHeaders = namedtuple('SndHeaders',
3838
'filetype framerate nchannels nframes sampwidth')
3939

40+
SndHeaders.filetype.__doc__ = ("""The value for type indicates the data type
41+
and will be one of the strings 'aifc', 'aiff', 'au','hcom',
42+
'sndr', 'sndt', 'voc', 'wav', '8svx', 'sb', 'ub', or 'ul'.""")
43+
SndHeaders.framerate.__doc__ = ("""The sampling_rate will be either the actual
44+
value or 0 if unknown or difficult to decode.""")
45+
SndHeaders.nchannels.__doc__ = ("""The number of channels or 0 if it cannot be
46+
determined or if the value is difficult to decode.""")
47+
SndHeaders.nframes.__doc__ = ("""The value for frames will be either the number
48+
of frames or -1.""")
49+
SndHeaders.sampwidth.__doc__ = ("""Either the sample size in bits or
50+
'A' for A-LAW or 'U' for u-LAW.""")
51+
4052
def what(filename):
4153
"""Guess the type of a sound file."""
4254
res = whathdr(filename)

0 commit comments

Comments
 (0)