bpo-45516: add protocol description to the Traversable documentation (#29039)

* bpo-45516: add protocol description to the Traversable documentation

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Update Doc/library/importlib.rst

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>

* Update Lib/importlib/abc.py

* Update Doc/library/importlib.rst

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
This commit is contained in:
Filipe Laíns 2021-10-18 23:58:13 +01:00 committed by GitHub
parent 6a533a4238
commit 4d03de3329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 0 deletions

View File

@ -815,6 +815,46 @@ ABC hierarchy::
.. versionadded:: 3.9
.. abstractmethod:: name()
The base name of this object without any parent references.
.. abstractmethod:: iterdir()
Yield Traversable objects in self.
.. abstractmethod:: is_dir()
Return True if self is a directory.
.. abstractmethod:: is_file()
Return True if self is a file.
.. abstractmethod:: joinpath(child)
Return Traversable child in self.
.. abstractmethod:: __truediv__(child)
Return Traversable child in self.
.. abstractmethod:: open(mode='r', *args, **kwargs)
*mode* may be 'r' or 'rb' to open as text or binary. Return a handle
suitable for reading (same as :attr:`pathlib.Path.open`).
When opening as text, accepts encoding parameters such as those
accepted by :attr:`io.TextIOWrapper`.
.. method:: read_bytes()
Read contents of self as bytes.
.. method:: read_text(encoding=None)
Read contents of self as text.
.. class:: TraversableResources

View File

@ -0,0 +1,2 @@
Add protocol description to the :class:`importlib.abc.Traversable`
documentation.