Skip to content

Commit bc3718e

Browse files
GH-101898: Fix missing term references for hashable definition (GH-101899)
Fix missing term references for hashable definition (cherry picked from commit 3690688) Co-authored-by: Furkan Onder <[email protected]>
1 parent 59852bb commit bc3718e

16 files changed

+22
-22
lines changed

Doc/c-api/dict.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Dictionary Objects
8080
8181
.. c:function:: int PyDict_DelItem(PyObject *p, PyObject *key)
8282
83-
Remove the entry in dictionary *p* with key *key*. *key* must be hashable;
83+
Remove the entry in dictionary *p* with key *key*. *key* must be :term:`hashable`;
8484
if it isn't, :exc:`TypeError` is raised.
8585
If *key* is not in the dictionary, :exc:`KeyError` is raised.
8686
Return ``0`` on success or ``-1`` on failure.

Doc/c-api/object.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ Object Protocol
263263
264264
.. c:function:: Py_hash_t PyObject_HashNotImplemented(PyObject *o)
265265
266-
Set a :exc:`TypeError` indicating that ``type(o)`` is not hashable and return ``-1``.
266+
Set a :exc:`TypeError` indicating that ``type(o)`` is not :term:`hashable` and return ``-1``.
267267
This function receives special treatment when stored in a ``tp_hash`` slot,
268268
allowing a type to explicitly indicate to the interpreter that it is not
269269
hashable.

Doc/faq/programming.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,7 @@ method result will be released right away. The disadvantage is that if
19651965
instances accumulate, so too will the accumulated method results. They
19661966
can grow without bound.
19671967

1968-
The *lru_cache* approach works with methods that have hashable
1968+
The *lru_cache* approach works with methods that have :term:`hashable`
19691969
arguments. It creates a reference to the instance unless special
19701970
efforts are made to pass in weak references.
19711971

Doc/library/abc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The :mod:`collections` module has some concrete classes that derive from
2121
ABCs; these can, of course, be further derived. In addition, the
2222
:mod:`collections.abc` submodule has some ABCs that can be used to test whether
2323
a class or instance provides a particular interface, for example, if it is
24-
hashable or if it is a mapping.
24+
:term:`hashable` or if it is a mapping.
2525

2626

2727
This module provides the metaclass :class:`ABCMeta` for defining ABCs and

Doc/library/collections.abc.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
This module provides :term:`abstract base classes <abstract base class>` that
2424
can be used to test whether a class provides a particular interface; for
25-
example, whether it is hashable or whether it is a mapping.
25+
example, whether it is :term:`hashable` or whether it is a mapping.
2626

2727
An :func:`issubclass` or :func:`isinstance` test for an interface works in one
2828
of three ways.
@@ -406,7 +406,7 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin:
406406
(3)
407407
The :class:`Set` mixin provides a :meth:`_hash` method to compute a hash value
408408
for the set; however, :meth:`__hash__` is not defined because not all sets
409-
are hashable or immutable. To add set hashability using mixins,
409+
are :term:`hashable` or immutable. To add set hashability using mixins,
410410
inherit from both :meth:`Set` and :meth:`Hashable`, then define
411411
``__hash__ = Set._hash``.
412412

Doc/library/collections.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Python's general purpose built-in containers, :class:`dict`, :class:`list`,
2525
:func:`namedtuple` factory function for creating tuple subclasses with named fields
2626
:class:`deque` list-like container with fast appends and pops on either end
2727
:class:`ChainMap` dict-like class for creating a single view of multiple mappings
28-
:class:`Counter` dict subclass for counting hashable objects
28+
:class:`Counter` dict subclass for counting :term:`hashable` objects
2929
:class:`OrderedDict` dict subclass that remembers the order entries were added
3030
:class:`defaultdict` dict subclass that calls a factory function to supply missing values
3131
:class:`UserDict` wrapper around dictionary objects for easier dict subclassing
@@ -241,7 +241,7 @@ For example::
241241

242242
.. class:: Counter([iterable-or-mapping])
243243

244-
A :class:`Counter` is a :class:`dict` subclass for counting hashable objects.
244+
A :class:`Counter` is a :class:`dict` subclass for counting :term:`hashable` objects.
245245
It is a collection where elements are stored as dictionary keys
246246
and their counts are stored as dictionary values. Counts are allowed to be
247247
any integer value including zero or negative counts. The :class:`Counter`

Doc/library/datetime.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ The :class:`date`, :class:`.datetime`, :class:`.time`, and :class:`timezone` typ
154154
share these common features:
155155

156156
- Objects of these types are immutable.
157-
- Objects of these types are hashable, meaning that they can be used as
157+
- Objects of these types are :term:`hashable`, meaning that they can be used as
158158
dictionary keys.
159159
- Objects of these types support efficient pickling via the :mod:`pickle` module.
160160

Doc/library/fractions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ another rational number, or from a string.
7676

7777
The :class:`Fraction` class inherits from the abstract base class
7878
:class:`numbers.Rational`, and implements all of the methods and
79-
operations from that class. :class:`Fraction` instances are hashable,
79+
operations from that class. :class:`Fraction` instances are :term:`hashable`,
8080
and should be treated as immutable. In addition,
8181
:class:`Fraction` has the following properties and methods:
8282

Doc/library/functools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ The :mod:`functools` module defines the following functions:
141141
function is periodically called with the same arguments.
142142

143143
Since a dictionary is used to cache results, the positional and keyword
144-
arguments to the function must be hashable.
144+
arguments to the function must be :term:`hashable`.
145145

146146
Distinct argument patterns may be considered to be distinct calls with
147147
separate cache entries. For example, `f(a=1, b=2)` and `f(b=2, a=1)`

Doc/library/graphlib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
.. class:: TopologicalSorter(graph=None)
1919

20-
Provides functionality to topologically sort a graph of hashable nodes.
20+
Provides functionality to topologically sort a graph of :term:`hashable` nodes.
2121

2222
A topological order is a linear ordering of the vertices in a graph such that
2323
for every directed edge u -> v from vertex u to vertex v, vertex u comes
@@ -85,7 +85,7 @@
8585
.. method:: add(node, *predecessors)
8686

8787
Add a new node and its predecessors to the graph. Both the *node* and all
88-
elements in *predecessors* must be hashable.
88+
elements in *predecessors* must be :term:`hashable`.
8989

9090
If called multiple times with the same node argument, the set of
9191
dependencies will be the union of all dependencies passed in.

Doc/library/inspect.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ function.
641641
modified copy.
642642

643643
.. versionchanged:: 3.5
644-
Signature objects are picklable and hashable.
644+
Signature objects are picklable and :term:`hashable`.
645645

646646
.. attribute:: Signature.empty
647647

@@ -719,7 +719,7 @@ function.
719719
you can use :meth:`Parameter.replace` to create a modified copy.
720720

721721
.. versionchanged:: 3.5
722-
Parameter objects are picklable and hashable.
722+
Parameter objects are picklable and :term:`hashable`.
723723

724724
.. attribute:: Parameter.empty
725725

Doc/library/operator.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ expect a function argument.
316316
return g
317317

318318
The items can be any type accepted by the operand's :meth:`__getitem__`
319-
method. Dictionaries accept any hashable value. Lists, tuples, and
319+
method. Dictionaries accept any :term:`hashable` value. Lists, tuples, and
320320
strings accept an index or a slice:
321321

322322
>>> itemgetter(1)('ABCDEFG')

Doc/library/pathlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ these classes, since they don't provide any operation that does system calls.
186186
General properties
187187
^^^^^^^^^^^^^^^^^^
188188

189-
Paths are immutable and hashable. Paths of a same flavour are comparable
189+
Paths are immutable and :term:`hashable`. Paths of a same flavour are comparable
190190
and orderable. These properties respect the flavour's case-folding
191191
semantics::
192192

Doc/library/stdtypes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3725,7 +3725,7 @@ copying.
37253725
>>> data
37263726
bytearray(b'z1spam')
37273727

3728-
One-dimensional memoryviews of hashable (read-only) types with formats
3728+
One-dimensional memoryviews of :term:`hashable` (read-only) types with formats
37293729
'B', 'b' or 'c' are also hashable. The hash is defined as
37303730
``hash(m) == hash(m.tobytes())``::
37313731

@@ -3739,7 +3739,7 @@ copying.
37393739

37403740
.. versionchanged:: 3.3
37413741
One-dimensional memoryviews can now be sliced.
3742-
One-dimensional memoryviews with formats 'B', 'b' or 'c' are now hashable.
3742+
One-dimensional memoryviews with formats 'B', 'b' or 'c' are now :term:`hashable`.
37433743

37443744
.. versionchanged:: 3.4
37453745
memoryview is now registered automatically with
@@ -4659,7 +4659,7 @@ support membership tests:
46594659

46604660
.. versionadded:: 3.10
46614661

4662-
Keys views are set-like since their entries are unique and hashable. If all
4662+
Keys views are set-like since their entries are unique and :term:`hashable`. If all
46634663
values are hashable, so that ``(key, value)`` pairs are unique and hashable,
46644664
then the items view is also set-like. (Values views are not treated as set-like
46654665
since the entries are generally not unique.) For set-like views, all of the

Doc/library/typing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ are intended primarily for static type checking.
425425

426426
A user-defined generic class can have ABCs as base classes without a metaclass
427427
conflict. Generic metaclasses are not supported. The outcome of parameterizing
428-
generics is cached, and most types in the typing module are hashable and
428+
generics is cached, and most types in the typing module are :term:`hashable` and
429429
comparable for equality.
430430

431431

Doc/reference/datamodel.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ Basic customization
14901490
:meth:`__hash__`, its instances will not be usable as items in hashable
14911491
collections. If a class defines mutable objects and implements an
14921492
:meth:`__eq__` method, it should not implement :meth:`__hash__`, since the
1493-
implementation of hashable collections requires that a key's hash value is
1493+
implementation of :term:`hashable` collections requires that a key's hash value is
14941494
immutable (if the object's hash value changes, it will be in the wrong hash
14951495
bucket).
14961496

0 commit comments

Comments
 (0)