Skip to content

Commit

Permalink
bpo-45516: add protocol description to the Traversable documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Filipe Laíns <lains@riseup.net>
  • Loading branch information
FFY00 committed Oct 18, 2021
1 parent 034f607 commit 13a6e1c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
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 directtory.

.. 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
2 changes: 1 addition & 1 deletion Lib/importlib/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def read_text(self, encoding=None):
@abc.abstractmethod
def is_dir(self) -> bool:
"""
Return True if self is a dir
Return True if self is a directory
"""

@abc.abstractmethod
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.

0 comments on commit 13a6e1c

Please sign in to comment.