-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-101100: Fix most Sphinx nitpicks in the glossary and stdtypes.rst
#112757
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,8 @@ Any object can be tested for truth value, for use in an :keyword:`if` or | |
.. index:: single: true | ||
|
||
By default, an object is considered true unless its class defines either a | ||
:meth:`~object.__bool__` method that returns ``False`` or a :meth:`__len__` method that | ||
:meth:`~object.__bool__` method that returns ``False`` or a | ||
:meth:`~object.__len__` method that | ||
returns zero, when called with the object. [1]_ Here are most of the built-in | ||
objects considered false: | ||
|
||
|
@@ -197,7 +198,7 @@ exception. | |
|
||
Two more operations with the same syntactic priority, :keyword:`in` and | ||
:keyword:`not in`, are supported by types that are :term:`iterable` or | ||
implement the :meth:`__contains__` method. | ||
implement the :meth:`~object.__contains__` method. | ||
|
||
.. _typesnumeric: | ||
|
||
|
@@ -717,7 +718,7 @@ that's defined for any rational number, and hence applies to all instances of | |
:class:`int` and :class:`fractions.Fraction`, and all finite instances of | ||
:class:`float` and :class:`decimal.Decimal`. Essentially, this function is | ||
given by reduction modulo ``P`` for a fixed prime ``P``. The value of ``P`` is | ||
made available to Python as the :attr:`modulus` attribute of | ||
made available to Python as the :attr:`~sys.hash_info.modulus` attribute of | ||
:data:`sys.hash_info`. | ||
|
||
.. impl-detail:: | ||
|
@@ -906,9 +907,9 @@ Generator Types | |
--------------- | ||
|
||
Python's :term:`generator`\s provide a convenient way to implement the iterator | ||
protocol. If a container object's :meth:`__iter__` method is implemented as a | ||
protocol. If a container object's :meth:`~iterator.__iter__` method is implemented as a | ||
generator, it will automatically return an iterator object (technically, a | ||
generator object) supplying the :meth:`__iter__` and :meth:`~generator.__next__` | ||
generator object) supplying the :meth:`!__iter__` and :meth:`~generator.__next__` | ||
methods. | ||
More information about generators can be found in :ref:`the documentation for | ||
the yield expression <yieldexpr>`. | ||
|
@@ -3672,7 +3673,7 @@ The conversion types are: | |
+------------+-----------------------------------------------------+-------+ | ||
| ``'b'`` | Bytes (any object that follows the | \(5) | | ||
| | :ref:`buffer protocol <bufferobjects>` or has | | | ||
| | :meth:`__bytes__`). | | | ||
| | :meth:`~object.__bytes__`). | | | ||
+------------+-----------------------------------------------------+-------+ | ||
| ``'s'`` | ``'s'`` is an alias for ``'b'`` and should only | \(6) | | ||
| | be used for Python2/3 code bases. | | | ||
|
@@ -4410,7 +4411,8 @@ The constructors for both classes work the same: | |
:meth:`symmetric_difference_update` methods will accept any iterable as an | ||
argument. | ||
|
||
Note, the *elem* argument to the :meth:`__contains__`, :meth:`remove`, and | ||
Note, the *elem* argument to the :meth:`~object.__contains__`, | ||
:meth:`remove`, and | ||
:meth:`discard` methods may be a set. To support searching for an equivalent | ||
frozenset, a temporary one is created from *elem*. | ||
|
||
|
@@ -5236,9 +5238,11 @@ instantiated from the type:: | |
TypeError: cannot create 'types.UnionType' instances | ||
|
||
.. note:: | ||
The :meth:`__or__` method for type objects was added to support the syntax | ||
``X | Y``. If a metaclass implements :meth:`__or__`, the Union may | ||
override it:: | ||
The :meth:`!__or__` method for type objects was added to support the syntax | ||
``X | Y``. If a metaclass implements :meth:`!__or__`, the Union may | ||
Comment on lines
+5241
to
+5242
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered linking to https://docs.python.org/3/reference/datamodel.html#object.__or__, but the data model only discusses implementing |
||
override it: | ||
|
||
.. doctest:: | ||
|
||
>>> class M(type): | ||
... def __or__(self, other): | ||
|
@@ -5250,7 +5254,7 @@ instantiated from the type:: | |
>>> C | int | ||
'Hello' | ||
>>> int | C | ||
int | __main__.C | ||
int | C | ||
|
||
.. seealso:: | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can refer to
io.BaseIO
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there's anything we could specifically link to for either method.
io.IOBase
does not haveread()
orwrite()
as abstract methods, so neitherIOBase.read
norIOBase.write
is explicitly documented currently.https://docs.python.org/3/library/io.html#io.IOBase
Here's all the
IOBase
docs say onread
andwrite
:Specific subclasses of
IOBase
implement versions ofread
andwrite
that either only work with raw binary streams or only work with text streamsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, and there is a reason to not declare them there. But there are many other references to
read
andwrite
. It would be nice to have the general interface of them be documented somewhere. It is a different issue.