Skip to content

Commit dfa015c

Browse files
chasonmerwok
authored andcommitted
bpo-31972: Improve docstrings for pathlib classes (#5310)
1 parent 08a6926 commit dfa015c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Lib/pathlib.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,9 @@ def __repr__(self):
584584

585585

586586
class PurePath(object):
587-
"""PurePath represents a filesystem path and offers operations which
587+
"""Base class for manipulating paths without I/O.
588+
589+
PurePath represents a filesystem path and offers operations which
588590
don't imply any actual filesystem I/O. Depending on your system,
589591
instantiating a PurePath will return either a PurePosixPath or a
590592
PureWindowsPath object. You can also instantiate either of these classes
@@ -939,11 +941,21 @@ def match(self, path_pattern):
939941

940942

941943
class PurePosixPath(PurePath):
944+
"""PurePath subclass for non-Windows systems.
945+
946+
On a POSIX system, instantiating a PurePath should return this object.
947+
However, you can also instantiate it directly on any system.
948+
"""
942949
_flavour = _posix_flavour
943950
__slots__ = ()
944951

945952

946953
class PureWindowsPath(PurePath):
954+
"""PurePath subclass for Windows systems.
955+
956+
On a Windows system, instantiating a PurePath should return this object.
957+
However, you can also instantiate it directly on any system.
958+
"""
947959
_flavour = _windows_flavour
948960
__slots__ = ()
949961

@@ -952,6 +964,14 @@ class PureWindowsPath(PurePath):
952964

953965

954966
class Path(PurePath):
967+
"""PurePath subclass that can make system calls.
968+
969+
Path represents a filesystem path but unlike PurePath, also offers
970+
methods to do system calls on path objects. Depending on your system,
971+
instantiating a Path will return either a PosixPath or a WindowsPath
972+
object. You can also instantiate a PosixPath or WindowsPath directly,
973+
but cannot instantiate a WindowsPath on a POSIX system or vice versa.
974+
"""
955975
__slots__ = (
956976
'_accessor',
957977
'_closed',
@@ -1427,9 +1447,17 @@ def expanduser(self):
14271447

14281448

14291449
class PosixPath(Path, PurePosixPath):
1450+
"""Path subclass for non-Windows systems.
1451+
1452+
On a POSIX system, instantiating a Path should return this object.
1453+
"""
14301454
__slots__ = ()
14311455

14321456
class WindowsPath(Path, PureWindowsPath):
1457+
"""Path subclass for Windows systems.
1458+
1459+
On a Windows system, instantiating a Path should return this object.
1460+
"""
14331461
__slots__ = ()
14341462

14351463
def owner(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve docstrings for `pathlib.PurePath` subclasses.

0 commit comments

Comments
 (0)