-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to using propcache for property caching (#9394)
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
- Loading branch information
Showing
15 changed files
with
29 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Switched to using the :mod:`propcache <propcache.api>` package for property caching | ||
-- by :user:`bdraco`. | ||
|
||
The :mod:`propcache <propcache.api>` package is derived from the property caching | ||
code in :mod:`yarl` and has been broken out to avoid maintaining it for multiple | ||
projects. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,11 @@ | |
import base64 | ||
import datetime | ||
import gc | ||
import platform | ||
import sys | ||
import weakref | ||
from math import ceil, modf | ||
from pathlib import Path | ||
from typing import Any, Dict, Iterator, Optional, Type, Union | ||
from typing import Dict, Iterator, Optional, Union | ||
from unittest import mock | ||
from urllib.request import getproxies_environment # type: ignore[attr-defined] | ||
|
||
|
@@ -24,9 +23,6 @@ | |
should_remove_content_length, | ||
) | ||
|
||
IS_PYPY = platform.python_implementation() == "PyPy" | ||
|
||
|
||
# ------------------- parse_mimetype ---------------------------------- | ||
|
||
|
||
|
@@ -227,59 +223,6 @@ def test_basic_auth_from_not_url() -> None: | |
helpers.BasicAuth.from_url("http://user:[email protected]") # type: ignore[arg-type] | ||
|
||
|
||
class ReifyMixin: | ||
reify: Type["helpers.reify[Any]"] | ||
|
||
def test_reify(self) -> None: | ||
class A: | ||
def __init__(self) -> None: | ||
self._cache: Dict[str, str] = {} | ||
|
||
@self.reify # type: ignore[misc] | ||
def prop(self) -> int: | ||
return 1 | ||
|
||
a = A() | ||
assert 1 == a.prop | ||
|
||
def test_reify_class(self) -> None: | ||
class A: | ||
def __init__(self) -> None: | ||
self._cache: Dict[str, str] = {} | ||
|
||
@self.reify # type: ignore[misc] | ||
def prop(self) -> int: | ||
"""Docstring.""" | ||
return 1 | ||
|
||
assert isinstance(A.prop, self.reify) # type: ignore[arg-type] | ||
assert "Docstring." == A.prop.__doc__ # type: ignore[arg-type] | ||
|
||
def test_reify_assignment(self) -> None: | ||
class A: | ||
def __init__(self) -> None: | ||
self._cache: Dict[str, str] = {} | ||
|
||
@self.reify # type: ignore[misc] | ||
def prop(self) -> int: | ||
return 1 | ||
|
||
a = A() | ||
|
||
with pytest.raises(AttributeError): | ||
a.prop = 123 | ||
|
||
|
||
class TestPyReify(ReifyMixin): | ||
reify = helpers.reify_py | ||
|
||
|
||
if not helpers.NO_EXTENSIONS and not IS_PYPY and hasattr(helpers, "reify_c"): | ||
|
||
class TestCReify(ReifyMixin): | ||
reify = helpers.reify_c # type: ignore[attr-defined,assignment] | ||
|
||
|
||
# ----------------------------------- is_ip_address() ---------------------- | ||
|
||
|
||
|