Skip to content

Commit d2dc4b1

Browse files
committed
Move _explode_path
1 parent 54acfa3 commit d2dc4b1

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

Lib/pathlib/types.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,6 @@
2323
_WritablePathT = TypeVar("_WritablePathT", bound="_WritablePath")
2424

2525

26-
def _explode_path(path: str, parser: "_PathParser") -> tuple[str, list[str]]:
27-
"""
28-
Split the path into a 2-tuple (anchor, parts), where *anchor* is the
29-
uppermost parent of the path (equivalent to path.parents[-1]), and
30-
*parts* is a reversed list of parts following the anchor.
31-
"""
32-
split = parser.split
33-
parent, name = split(path)
34-
names = []
35-
while path != parent:
36-
names.append(name)
37-
path = parent
38-
parent, name = split(path)
39-
return path, names
40-
41-
4226
@runtime_checkable
4327
class _PathParser(Protocol):
4428
"""Protocol for path parsers, which do low-level path manipulation.
@@ -55,6 +39,22 @@ def splitext(self, path: str) -> tuple[str, str]: ...
5539
def normcase(self, path: str) -> str: ...
5640

5741

42+
def _explode_path(path: str, parser: _PathParser) -> tuple[str, list[str]]:
43+
"""
44+
Split the path into a 2-tuple (anchor, parts), where *anchor* is the
45+
uppermost parent of the path (equivalent to path.parents[-1]), and
46+
*parts* is a reversed list of parts following the anchor.
47+
"""
48+
split = parser.split
49+
parent, name = split(path)
50+
names = []
51+
while path != parent:
52+
names.append(name)
53+
path = parent
54+
parent, name = split(path)
55+
return path, names
56+
57+
5858
@runtime_checkable
5959
class PathInfo(Protocol):
6060
"""Protocol for path info objects, which support querying the file type.

0 commit comments

Comments
 (0)