Skip to content

Commit

Permalink
reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Oct 25, 2024
1 parent 6c179cf commit afea6e5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions yarl/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def parse_path(path: str) -> tuple[str, tuple[str, ...]]:


class URLPath:
"""A class representing a URL path."""

__slots__ = ("_tail", "_root", "path")

def __init__(self, root: str, tail: tuple[str, ...]) -> None:
Expand All @@ -68,8 +70,11 @@ def name(self) -> str:

@property
def parts(self) -> tuple[str, ...]:
"""An object providing sequence-like access to the
components in the filesystem path."""
"""Return the parts of the path.
The parts is the sequence of segments that make up the path
including the root.
"""
return (self._root,) + self._tail if self._root else self._tail

def parents(self) -> Generator["URLPath", None, None]:
Expand Down

0 comments on commit afea6e5

Please sign in to comment.