Skip to content

Commit b96ab14

Browse files
committed
fix references in PEP
1 parent 9fdf962 commit b96ab14

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

pep-0661.rst

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Motivation
5151
==========
5252

5353
In May 2021, a question was brought up on the python-dev mailing list
54-
[#python-dev-thread]_ about how to better implement a sentinel value for
54+
[1]_ about how to better implement a sentinel value for
5555
``traceback.print_exception``. The existing implementation used the
5656
following common idiom::
5757

@@ -76,17 +76,16 @@ in the discussion:
7676
instance being created and thus comparisons using ``is`` failing
7777

7878
In the ensuing discussion, Victor Stinner supplied a list of currently used
79-
sentinel values in the Python standard library
80-
[#list-of-sentinels-in-stdlib]_. This showed that the need for sentinels is
81-
fairly common, that there are various implementation methods used even
82-
within the stdlib, and that many of these suffer from at least one of the
83-
three aforementioned drawbacks.
79+
sentinel values in the Python standard library [2]_. This showed that the
80+
need for sentinels is fairly common, that there are various implementation
81+
methods used even within the stdlib, and that many of these suffer from at
82+
least one of the three aforementioned drawbacks.
8483

8584
The discussion did not lead to any clear consensus on whether a standard
8685
implementation method is needed or desirable, whether the drawbacks mentioned
8786
are significant, nor which kind of implementation would be good.
8887

89-
A poll was created on discuss.python.org [#poll]_ to get a clearer sense of
88+
A poll [3]_ was created on discuss.python.org to get a clearer sense of
9089
the community's opinions. The poll's results were not conclusive, with 40%
9190
voting for "The status-quo is fine / there’s no need for consistency in
9291
this", but most voters voting for one or more standardized solutions.
@@ -151,7 +150,7 @@ be used rather than boolean checks such as ``if value:`` or ``if not value:``.
151150
Sentinel instances are truthy by default.
152151

153152
The names of sentinels are unique within each module. When calling
154-
``Sentinel()``in a module where a sentinel with that name was already
153+
``Sentinel()`` in a module where a sentinel with that name was already
155154
defined, the existing sentinel with that name will be returned. Sentinels
156155
with the same name in different modules will be distinct from each other.
157156

@@ -168,20 +167,19 @@ as ``Sentinel()`` will usually be able to recognize the module in which it was
168167
called. ``module_name`` should be supplied only in unusual cases when this
169168
automatic recognition does not work as intended, such as perhaps when using
170169
Jython or IronPython. This parallels the designs of ``Enum`` and
171-
``namedtuple``. For more details, see `PEP 435`_.
170+
``namedtuple``. For more details, see
171+
`PEP 435 <https://peps.python.org/pep-0435/#functional-api>`_.
172172

173173
The ``Sentinel`` class may be sub-classed. Instances of each sub-class will
174174
be unique, even if using the same name and module. This allows for
175175
customizing the behavior of sentinels, such as controlling their truthiness.
176176

177-
.. _PEP 435: https://peps.python.org/pep-0435/#functional-api
178-
179177

180178
Reference Implementation
181179
========================
182180

183-
The reference implementation is found in a dedicated GitHub repo
184-
[#reference-github-repo]_. A simplified version follows::
181+
The reference implementation is found in a dedicated GitHub repo [4]_. A
182+
simplified version follows::
185183

186184
_registry = {}
187185

@@ -236,7 +234,7 @@ This suffers from all of the drawbacks mentioned in the `Rationale`_ section.
236234

237235

238236
Add a single new sentinel value, such as ``MISSING`` or ``Sentinel``
239-
-----------------------------------------------------------------
237+
--------------------------------------------------------------------
240238

241239
Since such a value could be used for various things in various places, one
242240
could not always be confident that it would never be a valid value in some use
@@ -246,7 +244,7 @@ with confidence without needing to consider potential edge-cases.
246244
Additionally, it is useful to be able to provide a meaningful name and repr
247245
for a sentinel value, specific to the context where it is used.
248246

249-
Finally, this was a very unpopular option in the poll [#poll]_, with only 12%
247+
Finally, this was a very unpopular option in the poll [3]_, with only 12%
250248
of the votes voting for it.
251249

252250

@@ -274,8 +272,8 @@ Besides the excessive repetition, the repr is overly long:
274272
``<NotGivenType.NotGiven: 'NotGiven'>``. A shorter repr can be defined, at
275273
the expense of a bit more code and yet more repetition.
276274

277-
Finally, this option was the least popular among the nine options in the poll
278-
[#poll]_, being the only option to receive no votes.
275+
Finally, this option was the least popular among the nine options in the
276+
poll [3]_, being the only option to receive no votes.
279277

280278

281279
A sentinel class decorator
@@ -322,7 +320,7 @@ Define a recommended "standard" idiom, without supplying an implementation
322320
Most common exiting idioms have significant drawbacks. So far, no idiom
323321
has been found that is clear and concise while avoiding these drawbacks.
324322

325-
Also, in the poll on this subject [#poll]_, the options for recommending an
323+
Also, in the poll [3]_ on this subject, the options for recommending an
326324
idiom were unpopular, with the highest-voted option being voted for by only
327325
25% of the voters.
328326

@@ -331,7 +329,7 @@ Additional Notes
331329
================
332330

333331
* This PEP and the initial implementation are drafted in a dedicated GitHub
334-
repo [#reference-github-repo]_.
332+
repo [4]_.
335333

336334
* For sentinels defined in a class scope, to avoid potential name clashes,
337335
one should use the fully-qualified name of the variable in the module. Only
@@ -352,10 +350,10 @@ Additional Notes
352350
References
353351
==========
354352

355-
.. [#python-dev-thread] Python-Dev mailing list: `The repr of a sentinel <https://mail.python.org/archives/list/[email protected]/thread/ZLVPD2OISI7M4POMTR2FCQTE6TPMPTO3/>`_
356-
.. [#list-of-sentinels-in-stdlib] Python-Dev mailing list: `"The stdlib contains tons of sentinels" <https://mail.python.org/archives/list/[email protected]/message/JBYXQH3NV3YBF7P2HLHB5CD6V3GVTY55/>`_
357-
.. [#poll] discuss.python.org Poll: `Sentinel Values in the Stdlib <https://discuss.python.org/t/sentinel-values-in-the-stdlib/8810/>`_
358-
.. [#reference-github-repo] `Reference implementation at the taleinat/python-stdlib-sentinels GitHub repo <https://github.com/taleinat/python-stdlib-sentinels>`_
353+
.. [1] Python-Dev mailing list: `The repr of a sentinel <https://mail.python.org/archives/list/[email protected]/thread/ZLVPD2OISI7M4POMTR2FCQTE6TPMPTO3/>`_
354+
.. [2] Python-Dev mailing list: `"The stdlib contains tons of sentinels" <https://mail.python.org/archives/list/[email protected]/message/JBYXQH3NV3YBF7P2HLHB5CD6V3GVTY55/>`_
355+
.. [3] discuss.python.org Poll: `Sentinel Values in the Stdlib <https://discuss.python.org/t/sentinel-values-in-the-stdlib/8810/>`_
356+
.. [4] `Reference implementation at the taleinat/python-stdlib-sentinels GitHub repo <https://github.com/taleinat/python-stdlib-sentinels>`_
359357
.. [5] `bpo-44123: Make function parameter sentinel values true singletons <https://bugs.python.org/issue44123>`_
360358
.. [6] `The "sentinels" package on PyPI <https://pypi.org/project/sentinels/>`_
361359
.. [7] `The "sentinel" package on PyPI <https://pypi.org/project/sentinel/>`_

0 commit comments

Comments
 (0)