Skip to content

Commit edb802c

Browse files
committed
add doc8
1 parent 7ac139c commit edb802c

File tree

6 files changed

+92
-37
lines changed

6 files changed

+92
-37
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ repos:
4545
"flake8-implicit-str-concat==0.2.0",
4646
]
4747

48+
- repo: https://github.com/PyCQA/doc8
49+
rev: 0.11.0
50+
hooks:
51+
- id: doc8
52+
args: [--max-line-length=100]
53+
4854
- repo: https://github.com/sirosen/check-jsonschema
4955
rev: 0.14.2
5056
hooks:

docs/kernels.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ The user location takes priority over the system locations, and the case of the
121121
names is ignored, so selecting kernels works the same way whether or not the
122122
filesystem is case sensitive.
123123
Since kernelspecs show up in URLs and other places,
124-
a kernelspec is required to have a simple name, only containing ASCII letters, ASCII numbers, and the simple separators: ``-`` hyphen, ``.`` period, ``_`` underscore.
124+
a kernelspec is required to have a simple name, only containing ASCII letters,
125+
ASCII numbers, and the simple separators: ``-`` hyphen, ``.`` period, ``_``
126+
underscore.
125127

126128
Other locations may also be searched if the :envvar:`JUPYTER_PATH` environment
127129
variable is set.
@@ -143,7 +145,8 @@ JSON serialised dictionary containing the following keys and values:
143145
When loading notebooks, if no matching kernelspec key (may differ across machines)
144146
is found, a kernel with a matching `language` will be used.
145147
This allows a notebook written on any Python or Julia kernel to be properly associated
146-
with the user's Python or Julia kernel, even if they aren't listed under the same name as the author's.
148+
with the user's Python or Julia kernel, even if they aren't listed under the
149+
same name as the author's.
147150
- **interrupt_mode** (optional): May be either ``signal`` or ``message`` and
148151
specifies how a client is supposed to interrupt cell execution on this kernel,
149152
either by sending an interrupt ``signal`` via the operating system's

docs/messaging.rst

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ The message `header` contains information about the message,
100100
such as unique identifiers for the originating session and the actual message id,
101101
the type of message, the version of the Jupyter protocol,
102102
and the date the message was created.
103-
In addition, there is a username field, e.g. for the process that generated the message, if applicable.
104-
This can be useful in collaborative settings where multiple users may be interacting with the same kernel simultaneously,
103+
In addition, there is a username field, e.g. for the process that generated the
104+
message, if applicable.
105+
This can be useful in collaborative settings where multiple users may be
106+
interacting with the same kernel simultaneously,
105107
so that frontends can label the various messages in a meaningful way.
106108

107109
.. sourcecode:: python
@@ -173,7 +175,8 @@ Metadata
173175
--------
174176

175177
The `metadata` dict contains information about the message that is not part of the content.
176-
This is not often used, but can be an extra location to store information about requests and replies,
178+
This is not often used, but can be an extra location to store information about
179+
requests and replies,
177180
such as extensions adding information about request or execution context.
178181

179182
Content
@@ -254,7 +257,8 @@ but does not describe the actual *implementation* at the wire level in zeromq.
254257
This section describes the protocol that must be implemented by Jupyter kernels and clients
255258
talking to each other over zeromq.
256259

257-
The reference implementation of the message spec is our :class:`~jupyter_client.session.Session` class.
260+
The reference implementation of the message spec is our
261+
:class:`~jupyter_client.session.Session` class.
258262

259263
.. note::
260264

@@ -372,16 +376,20 @@ Request-Reply
372376

373377
In general, the ROUTER/DEALER sockets follow a request-reply pattern:
374378

375-
The client sends an ``<action>_request`` message (such as ``execute_request``) on its shell (DEALER) socket.
379+
The client sends an ``<action>_request`` message (such as ``execute_request``)
380+
on its shell (DEALER) socket.
376381
The kernel receives that request and immediately publishes a ``status: busy`` message on IOPub.
377-
The kernel then processes the request and sends the appropriate ``<action>_reply`` message, such as ``execute_reply``.
382+
The kernel then processes the request and sends the appropriate
383+
``<action>_reply`` message, such as ``execute_reply``.
378384
After processing the request and publishing associated IOPub messages, if any,
379385
the kernel publishes a ``status: idle`` message.
380-
This idle status message indicates that IOPub messages associated with a given request have all been received.
386+
This idle status message indicates that IOPub messages associated with a given
387+
request have all been received.
381388

382389
All reply messages have a ``'status'`` field, which will have one of the following values:
383390

384-
- ``status='ok'``: The request was processed successfully, and the remaining content of the reply is specified in the appropriate section below.
391+
- ``status='ok'``: The request was processed successfully, and the remaining
392+
content of the reply is specified in the appropriate section below.
385393
- ``status='error'``: The request failed due to an error.
386394
When status is 'error', the usual content of a successful reply should be omitted,
387395
instead the following fields should be present::
@@ -1115,7 +1123,8 @@ Message type: ``debug_reply``::
11151123

11161124
The ``content`` dicts of the `debug_request` and `debug_reply` messages respectively follow the specification of the `Request` and `Response` messages from the `Debug Adapter Protocol (DAP) <https://microsoft.github.io/debug-adapter-protocol/>`_ as of version 1.39 or later.
11171125

1118-
Debug requests and replies are sent over the `control` channel to prevent queuing behind execution requests.
1126+
Debug requests and replies are sent over the `control` channel to prevent
1127+
queuing behind execution requests.
11191128

11201129
Additions to the DAP
11211130
~~~~~~~~~~~~~~~~~~~~
@@ -1126,7 +1135,9 @@ The Jupyter debugger protocol makes several additions to the DAP:
11261135
- the `debugInfo` request and response messages
11271136
- the `inspectVariables` request and response messages
11281137

1129-
In order to support the debugging of notebook cells and of Jupyter consoles, which are not based on source files, we need a message to submit code to the debugger to which breakpoints can be added.
1138+
In order to support the debugging of notebook cells and of Jupyter consoles,
1139+
which are not based on source files, we need a message to submit code to the
1140+
debugger to which breakpoints can be added.
11301141

11311142
Content of the `dumpCell` request::
11321143

@@ -1148,7 +1159,10 @@ In order to support the debugging of notebook cells and of Jupyter consoles, whi
11481159
}
11491160
}
11501161

1151-
In order to support page reloading, or a client connecting at a later stage, Jupyter kernels must store the state of the debugger (such as breakpoints, whether the debugger is currently stopped). The `debugInfo` request is a DAP `Request` with no extra argument.
1162+
In order to support page reloading, or a client connecting at a later stage,
1163+
Jupyter kernels must store the state of the debugger (such as breakpoints,
1164+
whether the debugger is currently stopped). The `debugInfo` request is a DAP
1165+
`Request` with no extra argument.
11521166

11531167
Content of the `debugInfo` request::
11541168

@@ -1182,7 +1196,9 @@ In order to support page reloading, or a client connecting at a later stage, Jup
11821196

11831197
The `source_breakpoint` schema is specified by the Debug Adapter Protocol.
11841198

1185-
The `inspectVariables` is meant to retrieve the values of all the variables that have been defined in the kernel. It is a DAP `Request` with no extra argument.
1199+
The `inspectVariables` is meant to retrieve the values of all the variables
1200+
that have been defined in the kernel. It is a DAP `Request` with no extra
1201+
argument.
11861202

11871203
Content of the `inspectVariables` request::
11881204

@@ -1208,7 +1224,8 @@ The `inspectVariables` is meant to retrieve the values of all the variables that
12081224
}
12091225
}
12101226

1211-
The ``richInspectVariables`` request allows to get the rich representation of a variable that has been defined in the kernel.
1227+
The ``richInspectVariables`` request allows to get the rich representation of a
1228+
variable that has been defined in the kernel.
12121229

12131230
Content of the ``richInspectVariables`` request::
12141231

@@ -1598,7 +1615,8 @@ Custom Messages
15981615

15991616
.. versionadded:: 4.1
16001617

1601-
Message spec 4.1 (IPython 2.0) added a messaging system for developers to add their own objects with Frontend
1618+
Message spec 4.1 (IPython 2.0) added a messaging system for developers to add
1619+
their own objects with Frontend
16021620
and Kernel-side components, and allow them to communicate with each other.
16031621
To do this, IPython adds a notion of a ``Comm``, which exists on both sides,
16041622
and can communicate in either direction.
@@ -1623,7 +1641,8 @@ The code handling the message on the receiving side is responsible for maintaini
16231641
of target_name keys to constructors.
16241642
After a ``comm_open`` message has been sent,
16251643
there should be a corresponding Comm instance on both sides.
1626-
The ``data`` key is always a dict and can be any extra JSON information used in initialization of the comm.
1644+
The ``data`` key is always a dict and can be any extra JSON information used in
1645+
initialization of the comm.
16271646

16281647
If the ``target_name`` key is not found on the receiving side,
16291648
then it should immediately reply with a ``comm_close`` message to avoid an inconsistent state.
@@ -1635,7 +1654,8 @@ Comm Messages
16351654
Comm messages are one-way communications to update comm state,
16361655
used for synchronizing widget state, or simply requesting actions of a comm's counterpart.
16371656

1638-
Essentially, each comm pair defines their own message specification implemented inside the ``data`` dict.
1657+
Essentially, each comm pair defines their own message specification implemented
1658+
inside the ``data`` dict.
16391659

16401660
There are no expected replies (of course, one side can send another ``comm_msg`` in reply).
16411661

@@ -1740,12 +1760,14 @@ Kernel info:
17401760

17411761
Execution:
17421762

1743-
- ``user_variables`` is removed from ``execute_request/reply`` because it is redundant with ``user_expressions``
1763+
- ``user_variables`` is removed from ``execute_request/reply`` because it is
1764+
redundant with ``user_expressions``
17441765
- ``password`` key added to ``input_request``
17451766

17461767
Output:
17471768

1748-
- ``data`` key in stream messages renamed to ``text`` for consistency with the notebook format.
1769+
- ``data`` key in stream messages renamed to ``text`` for consistency with the
1770+
notebook format.
17491771
- ``application/json`` in mimebundles should be unpacked JSON data,
17501772
not a double-serialized JSON string.
17511773

@@ -1758,7 +1780,8 @@ Inspection:
17581780

17591781
Completion:
17601782

1761-
- ``complete_request``: ``line``, ``block``, and ``text`` keys are removed in favor of a single ``code`` for context.
1783+
- ``complete_request``: ``line``, ``block``, and ``text`` keys are removed in
1784+
favor of a single ``code`` for context.
17621785
Lexing is up to the kernel.
17631786
- ``complete_reply``:
17641787
- ``matched_text`` is removed in favor of ``cursor_start`` and ``cursor_end``.
@@ -1769,7 +1792,8 @@ Completion:
17691792
---
17701793

17711794
- ``comm_open/close/msg`` messages added
1772-
- ``clear_output``: ``stdout``, ``stderr``, and ``display`` boolean keys for selective clearing are removed,
1795+
- ``clear_output``: ``stdout``, ``stderr``, and ``display`` boolean keys for
1796+
selective clearing are removed,
17731797
and ``wait`` is added.
17741798
The selective clearing keys are ignored in v4 and the default behavior remains the same,
17751799
so v4 ``clear_output`` messages will be safely handled by a v4.1 frontend.
@@ -1785,7 +1809,8 @@ Notes
17851809

17861810
Many frontends, especially those implemented in javascript,
17871811
reported cursor_pos as the interpreter's string index,
1788-
which is not the same as the unicode character offset if the interpreter uses UTF-16 (e.g. javascript or Python 2 on macOS),
1812+
which is not the same as the unicode character offset if the interpreter uses
1813+
UTF-16 (e.g. javascript or Python 2 on macOS),
17891814
which stores "astral-plane" characters such as ``𝐚 (U+1D41A)`` as surrogate pairs,
17901815
taking up two indices instead of one, causing a unicode offset
17911816
drift of one per astral-plane character.
@@ -1797,11 +1822,16 @@ for frontends that did the right thing.
17971822

17981823
For this reason, in protocol versions prior to 5.2, ``cursor_pos``
17991824
is officially ambiguous in the presence of astral plane unicode characters.
1800-
Frontends claiming to implement protocol 5.2 **MUST** identify cursor_pos as the encoding-independent unicode character offset.
1801-
Kernels may choose to expect the UTF-16 offset from requests implementing protocol 5.1 and earlier, in order to behave correctly with the most popular frontends.
1802-
But they should know that doing so *introduces* the inverse bug for the frontends that do not have this bug.
1803-
1804-
As an example, use a python3 kernel and evaluate ``𨭎𨭎𨭎𨭎𨭎 = 10``. Then type ``𨭎𨭎`` followed by the tab key and see if it properly completes.
1825+
Frontends claiming to implement protocol 5.2 **MUST** identify cursor_pos as
1826+
the encoding-independent unicode character offset.
1827+
Kernels may choose to expect the UTF-16 offset from requests implementing
1828+
protocol 5.1 and earlier, in order to behave correctly with the most popular
1829+
frontends.
1830+
But they should know that doing so *introduces* the inverse bug for the
1831+
frontends that do not have this bug.
1832+
1833+
As an example, use a python3 kernel and evaluate ``𨭎𨭎𨭎𨭎𨭎 = 10``. Then type
1834+
``𨭎𨭎`` followed by the tab key and see if it properly completes.
18051835

18061836
Known affected frontends (as of 2017-06):
18071837

docs/pending-kernels.rst

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ Pending Kernels
33

44
*Added in 7.1.0*
55

6-
In scenarios where an kernel takes a long time to start (e.g. kernels running remotely), it can be advantageous to immediately return the kernel's model and ID from key methods like ``.start_kernel()`` and ``.shutdown_kernel()``. The kernel will continue its task without blocking other managerial actions.
6+
In scenarios where an kernel takes a long time to start (e.g. kernels running
7+
remotely), it can be advantageous to immediately return the kernel's model and
8+
ID from key methods like ``.start_kernel()`` and ``.shutdown_kernel()``. The
9+
kernel will continue its task without blocking other managerial actions.
710

811
This intermediate state is called a **"pending kernel"**.
912

1013
How they work
1114
-------------
1215

13-
When ``.start_kernel()`` or ``.shutdown_kernel()`` is called, a ``Future`` is created under the ``KernelManager.ready`` property. This property can be awaited anytime to ensure that the kernel moves out of its pending state, e.g.:
16+
When ``.start_kernel()`` or ``.shutdown_kernel()`` is called, a ``Future`` is
17+
created under the ``KernelManager.ready`` property. This property can be
18+
awaited anytime to ensure that the kernel moves out of its pending state, e.g.:
1419

1520
.. code-block:: python
1621
@@ -19,18 +24,26 @@ When ``.start_kernel()`` or ``.shutdown_kernel()`` is called, a ``Future`` is cr
1924
# of its pending state.
2025
await kernel_manager.ready
2126
22-
Once the kernel is finished pending, ``.ready.done()`` will be ``True`` and either 1) ``.ready.result()`` will return ``None`` or 2) ``.ready.exception()`` will return a raised exception
27+
Once the kernel is finished pending, ``.ready.done()`` will be ``True`` and
28+
either 1) ``.ready.result()`` will return ``None`` or 2) ``.ready.exception()``
29+
will return a raised exception
2330

2431
Using pending kernels
2532
---------------------
2633

27-
The most common way to interact with pending kernels is through the ``MultiKernelManager``—the object that manages a collection of kernels—by setting its ``use_pending_kernels`` trait to ``True``. Pending kernels are "opt-in"; they are not used by default in the ``MultiKernelManager``.
34+
The most common way to interact with pending kernels is through the ``
35+
MultiKernelManager``—the object that manages a collection of kernels—by setting
36+
its ``use_pending_kernels`` trait to ``True``. Pending kernels are "opt-in";
37+
they are not used by default in the ``MultiKernelManager``.
2838

29-
When ``use_pending_kernels`` is ``True``, the following changes are made to the ``MultiKernelManager``:
39+
When ``use_pending_kernels`` is ``True``, the following changes are made to the
40+
``MultiKernelManager``:
3041

31-
1. ``start_kernel`` and ``stop_kernel`` return immediately while running the pending task in a background thread.
42+
1. ``start_kernel`` and ``stop_kernel`` return immediately while running the
43+
pending task in a background thread.
3244
2. The following methods raise a ``RuntimeError`` if a kernel is pending:
3345
* ``restart_kernel``
3446
* ``interrupt_kernel``
3547
* ``shutdown_kernel``
36-
3. ``shutdown_all`` will wait for all pending kernels to become ready before attempting to shut them down.
48+
3. ``shutdown_all`` will wait for all pending kernels to become ready before
49+
attempting to shut them down.

docs/provisioning.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ behavior, there's a good chance you can simply extend
139139
custom functionality.
140140

141141
In this example, RBACProvisioner will verify whether the current user is
142-
in the role meant for this kernel by calling a method implemented within *this* provisioner. If the user is not in the role, an exception will be thrown.
142+
in the role meant for this kernel by calling a method implemented within *this*
143+
provisioner. If the user is not in the role, an exception will be thrown.
143144

144145
.. code:: python
145146

docs/wrapperkernels.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ such as bash.
1414
A simple kernel for bash, written using this machinery
1515

1616
The `Metakernel <https://github.com/Calysto/metakernel/#>`_ library makes it easier to
17-
write a wrapper kernel that includes a base set of line and cell magics. It also has a ``ProcessKernel`` subclass that makes it easy to write kernels that use ``pexpect``.
17+
write a wrapper kernel that includes a base set of line and cell magics. It
18+
also has a ``ProcessKernel`` subclass that makes it easy to write kernels that
19+
use ``pexpect``.
1820
See `Octave Kernel <https://github.com/Calysto/octave_kernel>`_ as an example.
1921

2022

0 commit comments

Comments
 (0)