Skip to content

Commit 13a6e1c

Browse files
committed
bpo-45516: add protocol description to the Traversable documentation
Signed-off-by: Filipe Laíns <[email protected]>
1 parent 034f607 commit 13a6e1c

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
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 directtory.
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

Lib/importlib/abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def read_text(self, encoding=None):
381381
@abc.abstractmethod
382382
def is_dir(self) -> bool:
383383
"""
384-
Return True if self is a dir
384+
Return True if self is a directory
385385
"""
386386

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