Skip to content

Commit 93342ba

Browse files
committed
Normalize docstring formatting
1 parent 4e6aadc commit 93342ba

File tree

5 files changed

+62
-31
lines changed

5 files changed

+62
-31
lines changed

mitogen/core.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -337,19 +337,25 @@ class ChannelError(Error):
337337

338338

339339
class StreamError(Error):
340-
"""Raised when a stream cannot be established."""
340+
"""
341+
Raised when a stream cannot be established.
342+
"""
341343
pass
342344

343345

344346
class TimeoutError(Error):
345-
"""Raised when a timeout occurs on a stream."""
347+
"""
348+
Raised when a timeout occurs on a stream.
349+
"""
346350
pass
347351

348352

349353
def to_text(o):
350-
"""Coerce `o` to Unicode by decoding it from UTF-8 if it is an instance of
354+
"""
355+
Coerce `o` to Unicode by decoding it from UTF-8 if it is an instance of
351356
:class:`bytes`, otherwise pass it to the :class:`str` constructor. The
352-
returned object is always a plain :class:`str`, any subclass is removed."""
357+
returned object is always a plain :class:`str`, any subclass is removed.
358+
"""
353359
if isinstance(o, BytesType):
354360
return o.decode('utf-8')
355361
return UnicodeType(o)
@@ -1952,7 +1958,9 @@ def pending_bytes(self):
19521958
return self._writer._len
19531959

19541960
def on_transmit(self, broker):
1955-
"""Transmit buffered messages."""
1961+
"""
1962+
Transmit buffered messages.
1963+
"""
19561964
_vv and IOLOG.debug('%r.on_transmit()', self)
19571965
self._writer.on_transmit(broker)
19581966

@@ -1961,12 +1969,16 @@ def _send(self, msg):
19611969
self._writer.write(msg.pack())
19621970

19631971
def send(self, msg):
1964-
"""Send `data` to `handle`, and tell the broker we have output. May
1965-
be called from any thread."""
1972+
"""
1973+
Send `data` to `handle`, and tell the broker we have output. May be
1974+
called from any thread.
1975+
"""
19661976
self._router.broker.defer(self._send, msg)
19671977

19681978
def on_shutdown(self, broker):
1969-
"""Disable :class:`Protocol` immediate disconnect behaviour."""
1979+
"""
1980+
Disable :class:`Protocol` immediate disconnect behaviour.
1981+
"""
19701982
_v and LOG.debug('%r: shutting down', self)
19711983

19721984

@@ -2628,7 +2640,9 @@ def __init__(self, name):
26282640
self._log.handlers = logging.getLogger().handlers[:]
26292641

26302642
def on_shutdown(self, broker):
2631-
"""Shut down the write end of the logging socket."""
2643+
"""
2644+
Shut down the write end of the logging socket.
2645+
"""
26322646
_v and LOG.debug('%r: shutting down', self)
26332647
if not IS_WSL:
26342648
# #333: WSL generates invalid readiness indication on shutdown().
@@ -2912,8 +2926,10 @@ def _on_respondent_disconnect(self, context):
29122926
del self._handle_map[handle]
29132927

29142928
def on_shutdown(self, broker):
2915-
"""Called during :meth:`Broker.shutdown`, informs callbacks registered
2916-
with :meth:`add_handle_cb` the connection is dead."""
2929+
"""
2930+
Called during :meth:`Broker.shutdown`, informs callbacks registered
2931+
with :meth:`add_handle_cb` the connection is dead.
2932+
"""
29172933
_v and LOG.debug('%r: shutting down', self, broker)
29182934
fire(self, 'shutdown')
29192935
for handle, (persist, fn) in self._handle_map.iteritems():

mitogen/master.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@
9191

9292

9393
def _stdlib_paths():
94-
"""Return a set of paths from which Python imports the standard library.
94+
"""
95+
Return a set of paths from which Python imports the standard library.
9596
"""
9697
attr_candidates = [
9798
'prefix',
@@ -111,8 +112,8 @@ def _stdlib_paths():
111112

112113

113114
def is_stdlib_name(modname):
114-
"""Return :data:`True` if `modname` appears to come from the standard
115-
library.
115+
"""
116+
Return :data:`True` if `modname` appears to come from the standard library.
116117
"""
117118
if imp.is_builtin(modname) != 0:
118119
return True
@@ -139,7 +140,8 @@ def is_stdlib_path(path):
139140

140141

141142
def get_child_modules(path):
142-
"""Return the suffixes of submodules directly neated beneath of the package
143+
"""
144+
Return the suffixes of submodules directly neated beneath of the package
143145
directory at `path`.
144146
145147
:param str path:
@@ -301,8 +303,10 @@ class ThreadWatcher(object):
301303

302304
@classmethod
303305
def _reset(cls):
304-
"""If we have forked since the watch dictionaries were initialized, all
305-
that has is garbage, so clear it."""
306+
"""
307+
If we have forked since the watch dictionaries were initialized, all
308+
that has is garbage, so clear it.
309+
"""
306310
if os.getpid() != cls._cls_pid:
307311
cls._cls_pid = os.getpid()
308312
cls._cls_instances_by_target.clear()
@@ -668,7 +672,8 @@ def add_source_override(self, fullname, path, source, is_pkg):
668672
]
669673

670674
def get_module_source(self, fullname):
671-
"""Given the name of a loaded module `fullname`, attempt to find its
675+
"""
676+
Given the name of a loaded module `fullname`, attempt to find its
672677
source code.
673678
674679
:returns:
@@ -692,9 +697,10 @@ def get_module_source(self, fullname):
692697
return tup
693698

694699
def resolve_relpath(self, fullname, level):
695-
"""Given an ImportFrom AST node, guess the prefix that should be tacked
696-
on to an alias name to produce a canonical name. `fullname` is the name
697-
of the module in which the ImportFrom appears.
700+
"""
701+
Given an ImportFrom AST node, guess the prefix that should be tacked on
702+
to an alias name to produce a canonical name. `fullname` is the name of
703+
the module in which the ImportFrom appears.
698704
"""
699705
mod = sys.modules.get(fullname, None)
700706
if hasattr(mod, '__path__'):
@@ -845,9 +851,11 @@ def blacklist_prefix(self, fullname):
845851
self.blacklist.append(fullname)
846852

847853
def neutralize_main(self, path, src):
848-
"""Given the source for the __main__ module, try to find where it
849-
begins conditional execution based on a "if __name__ == '__main__'"
850-
guard, and remove any code after that point."""
854+
"""
855+
Given the source for the __main__ module, try to find where it begins
856+
conditional execution based on a "if __name__ == '__main__'" guard, and
857+
remove any code after that point.
858+
"""
851859
match = self.MAIN_RE.search(src)
852860
if match:
853861
return src[:match.start()]

mitogen/minify.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444

4545

4646
def minimize_source(source):
47-
"""Remove comments and docstrings from Python `source`, preserving line
47+
"""
48+
Remove comments and docstrings from Python `source`, preserving line
4849
numbers and syntax of empty blocks.
4950
5051
:param str source:
@@ -62,7 +63,8 @@ def minimize_source(source):
6263

6364

6465
def strip_comments(tokens):
65-
"""Drop comment tokens from a `tokenize` stream.
66+
"""
67+
Drop comment tokens from a `tokenize` stream.
6668
6769
Comments on lines 1-2 are kept, to preserve hashbang and encoding.
6870
Trailing whitespace is remove from all lines.
@@ -84,7 +86,8 @@ def strip_comments(tokens):
8486

8587

8688
def strip_docstrings(tokens):
87-
"""Replace docstring tokens with NL tokens in a `tokenize` stream.
89+
"""
90+
Replace docstring tokens with NL tokens in a `tokenize` stream.
8891
8992
Any STRING token not part of an expression is deemed a docstring.
9093
Indented docstrings are not yet recognised.
@@ -119,7 +122,8 @@ def strip_docstrings(tokens):
119122

120123

121124
def reindent(tokens, indent=' '):
122-
"""Replace existing indentation in a token steam, with `indent`.
125+
"""
126+
Replace existing indentation in a token steam, with `indent`.
123127
"""
124128
old_levels = []
125129
old_level = 0

mitogen/parent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,9 @@ def _fail_connection(self, exc):
14291429
self._complete_connection()
14301430

14311431
def on_stream_shutdown(self):
1432-
"""Request the slave gracefully shut itself down."""
1432+
"""
1433+
Request the slave gracefully shut itself down.
1434+
"""
14331435
LOG.debug('%r: requesting child shutdown', self)
14341436
self.stream.protocol._send(
14351437
mitogen.core.Message(

mitogen/profiler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
# !mitogen: minify_safe
3030

31-
"""mitogen.profiler
31+
"""
32+
mitogen.profiler
3233
Record and report cProfile statistics from a run. Creates one aggregated
3334
output file, one aggregate containing only workers, and one for the
3435
top-level process.
@@ -152,7 +153,7 @@ def do_stat(tmpdir, sort, *args):
152153

153154
def main():
154155
if len(sys.argv) < 2 or sys.argv[1] not in ('record', 'report', 'stat'):
155-
sys.stderr.write(__doc__)
156+
sys.stderr.write(__doc__.lstrip())
156157
sys.exit(1)
157158

158159
func = globals()['do_' + sys.argv[1]]

0 commit comments

Comments
 (0)