Skip to content
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

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

Merged
merged 4 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add protocol description to the :class:`importlib.abc.Traversable`
documentation.