Skip to content

Commit e764f8c

Browse files
gnpricegvanrossum
authored andcommitted
Revise stub-files section in docs (#1658)
Adjust the style to match the informal tone of the rest of our docs in a couple of spots where it didn't. Also make small fixes to the code style in the example, and small wording tweaks.
1 parent b811c8a commit e764f8c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

docs/source/type_inference_and_annotations.rst

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,22 @@ Here, the type of ``rs`` is set to ``List[int]``.
151151
Types in stub files
152152
*******************
153153

154-
Recall the introductory note about the usage of stub files (See :ref:`library-stubs`)
155-
as an alternative approach to annotate types. Stub files are valid
156-
Python 3 files, which mirror the python modules but leave out the
157-
runtime logic like variable initialization, function bodies and
158-
default arguments. For example:
154+
:ref:`Stub files <library-stubs>` are written in normal Python 3
155+
syntax, but generally leaving out runtime logic like variable
156+
initializers, function bodies, and default arguments, replacing them
157+
with ellipses.
158+
159+
In this example, each ellipsis ``...`` is literally written in the
160+
stub file as three dots:
159161

160162
.. code-block:: python
161163
162-
x = ... # type: int
164+
x = ... # type: int
163165
def afunc(code: str) -> int: ...
164-
def afunc(a: int, b: int=...) -> int: pass
165-
166-
The literal ``...`` is all that's necessary!
166+
def afunc(a: int, b: int=...) -> int: ...
167167
168168
.. note::
169169

170-
The ``...`` is also used with a different meaning in the :ref:`Callable <callable-types>` and :ref:`Tuple <tuple-types>` types.
170+
The ellipsis ``...`` is also used with a different meaning in
171+
:ref:`callable types <callable-types>` and :ref:`tuple types
172+
<tuple-types>`.

0 commit comments

Comments
 (0)