Skip to content

Commit 4d03de3

Browse files
FFY00jaraco
andauthored
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 <[email protected]> * Update Doc/library/importlib.rst Co-authored-by: Jason R. Coombs <[email protected]> * Update Lib/importlib/abc.py * Update Doc/library/importlib.rst Co-authored-by: Jason R. Coombs <[email protected]> Co-authored-by: Jason R. Coombs <[email protected]>
1 parent 6a533a4 commit 4d03de3

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Doc/library/importlib.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,46 @@ ABC hierarchy::
815815

816816
.. versionadded:: 3.9
817817

818+
.. abstractmethod:: name()
819+
820+
The base name of this object without any parent references.
821+
822+
.. abstractmethod:: iterdir()
823+
824+
Yield Traversable objects in self.
825+
826+
.. abstractmethod:: is_dir()
827+
828+
Return True if self is a directory.
829+
830+
.. abstractmethod:: is_file()
831+
832+
Return True if self is a file.
833+
834+
.. abstractmethod:: joinpath(child)
835+
836+
Return Traversable child in self.
837+
838+
.. abstractmethod:: __truediv__(child)
839+
840+
Return Traversable child in self.
841+
842+
.. abstractmethod:: open(mode='r', *args, **kwargs)
843+
844+
*mode* may be 'r' or 'rb' to open as text or binary. Return a handle
845+
suitable for reading (same as :attr:`pathlib.Path.open`).
846+
847+
When opening as text, accepts encoding parameters such as those
848+
accepted by :attr:`io.TextIOWrapper`.
849+
850+
.. method:: read_bytes()
851+
852+
Read contents of self as bytes.
853+
854+
.. method:: read_text(encoding=None)
855+
856+
Read contents of self as text.
857+
818858

819859
.. class:: TraversableResources
820860

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add protocol description to the :class:`importlib.abc.Traversable`
2+
documentation.

0 commit comments

Comments
 (0)