Skip to content

Commit fb25462

Browse files
authored
Add missing type for _val to _InternalURLCache TypedDict (#1403)
1 parent 979e06a commit fb25462

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

yarl/_parse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
UNSAFE_URL_BYTES_TO_REMOVE = ["\t", "\r", "\n"]
2020
USES_AUTHORITY = frozenset(uses_netloc)
2121

22-
SplitURL = tuple[str, str, str, str, str]
22+
SplitURLType = tuple[str, str, str, str, str]
2323

2424

25-
def split_url(url: str) -> SplitURL:
25+
def split_url(url: str) -> SplitURLType:
2626
"""Split URL into parts."""
2727
# Adapted from urllib.parse.urlsplit
2828
# Only lstrip url as some applications rely on preserving trailing space.

yarl/_url.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from ._parse import (
1616
USES_AUTHORITY,
17-
SplitURL,
17+
SplitURLType,
1818
make_netloc,
1919
split_netloc,
2020
split_url,
@@ -97,6 +97,7 @@ class CacheInfo(TypedDict):
9797

9898

9999
class _InternalURLCache(TypedDict, total=False):
100+
_val: SplitURLType
100101
_origin: "URL"
101102
absolute: bool
102103
scheme: str
@@ -419,10 +420,6 @@ def build(
419420
url._cache = {}
420421
return url
421422

422-
@cached_property
423-
def _val(self) -> SplitURL:
424-
return (self._scheme, self._netloc, self._path, self._query, self._fragment)
425-
426423
@classmethod
427424
def _from_parts(
428425
cls, scheme: str, netloc: str, path: str, query: str, fragment: str
@@ -568,6 +565,10 @@ def origin(self) -> "URL":
568565
# TODO: add a keyword-only option for keeping user/pass maybe?
569566
return self._origin
570567

568+
@cached_property
569+
def _val(self) -> SplitURLType:
570+
return (self._scheme, self._netloc, self._path, self._query, self._fragment)
571+
571572
@cached_property
572573
def _origin(self) -> "URL":
573574
"""Return an URL with scheme, host and port parts only.

0 commit comments

Comments
 (0)