]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45516: add protocol description to the Traversable documentation (#29039)
authorFilipe Laíns <filipe.lains@gmail.com>
Mon, 18 Oct 2021 22:58:13 +0000 (23:58 +0100)
committerGitHub <noreply@github.com>
Mon, 18 Oct 2021 22:58:13 +0000 (18:58 -0400)
* bpo-45516: add protocol description to the Traversable documentation

Signed-off-by: Filipe Laíns <lains@riseup.net>
* Update Doc/library/importlib.rst

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* Update Lib/importlib/abc.py

* Update Doc/library/importlib.rst

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Doc/library/importlib.rst
Misc/NEWS.d/next/Documentation/2021-10-18-20-12-18.bpo-45516.EJh4K8.rst [new file with mode: 0644]

index b5ee7a6b9659afcdc33fbe671141f5a3d76e35ca..3576941efa46d96695c08da51fef1eee4a7c7a24 100644 (file)
@@ -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
 
diff --git a/Misc/NEWS.d/next/Documentation/2021-10-18-20-12-18.bpo-45516.EJh4K8.rst b/Misc/NEWS.d/next/Documentation/2021-10-18-20-12-18.bpo-45516.EJh4K8.rst
new file mode 100644 (file)
index 0000000..98f5d34
--- /dev/null
@@ -0,0 +1,2 @@
+Add protocol description to the :class:`importlib.abc.Traversable`
+documentation.