]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38422: Clarify docstrings of pathlib suffix(es) (GH-16679)
authorMiss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 2 Nov 2019 17:04:18 +0000 (10:04 -0700)
committerGitHub <noreply@github.com>
Sat, 2 Nov 2019 17:04:18 +0000 (10:04 -0700)
Whenever I use `path.suffix` I have to check again whether it includes the dot or not. I decided to add it to the docstring so I won't have to keep checking.

https://bugs.python.org/issue38422

Automerge-Triggered-By: @pitrou
(cherry picked from commit 8d4fef4ee2a318097f429cf6cbd4fb2e430bb9da)

Co-authored-by: Ram Rachum <ram@rachum.com>
Lib/pathlib.py
Misc/NEWS.d/next/Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst [new file with mode: 0644]

index af9747ba3cb992ec6b74dc84846fb5953fefe8eb..d868254bc5512cf61fc54b0672036f3a779d3eef 100644 (file)
@@ -797,7 +797,11 @@ class PurePath(object):
 
     @property
     def suffix(self):
-        """The final component's last suffix, if any."""
+        """
+        The final component's last suffix, if any.
+
+        This includes the leading period. For example: '.txt'
+        """
         name = self.name
         i = name.rfind('.')
         if 0 < i < len(name) - 1:
@@ -807,7 +811,11 @@ class PurePath(object):
 
     @property
     def suffixes(self):
-        """A list of the final component's suffixes, if any."""
+        """
+        A list of the final component's suffixes, if any.
+
+        These include the leading periods. For example: ['.tar', '.gz']
+        """
         name = self.name
         if name.endswith('.'):
             return []
diff --git a/Misc/NEWS.d/next/Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst b/Misc/NEWS.d/next/Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst
new file mode 100644 (file)
index 0000000..0958fe2
--- /dev/null
@@ -0,0 +1 @@
+Clarify docstrings of pathlib suffix(es)