Skip to content

Commit b04b307

Browse files
bpo-45516: add protocol description to the Traversable documentation (GH-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]> (cherry picked from commit 4d03de3) Co-authored-by: Filipe Laíns <[email protected]>
1 parent ed807bf commit b04b307

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
@@ -805,6 +805,46 @@ ABC hierarchy::
805805

806806
.. versionadded:: 3.9
807807

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

809849
.. class:: TraversableResources
810850

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)