Skip to content

Commit

Permalink
feat: add support for propcache v1.0.0+ (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 6, 2024
1 parent fcce4a9 commit b37f833
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/uiprotect/_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Compat for external lib versions."""

try:
from propcache.api import cached_property
except ImportError:
from propcache import cached_property

__all__ = ("cached_property",)
2 changes: 1 addition & 1 deletion src/uiprotect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from aiofiles import os as aos
from aiohttp import CookieJar, client_exceptions
from platformdirs import user_cache_dir, user_config_dir
from propcache import cached_property
from yarl import URL

from ._compat import cached_property
from .data import (
NVR,
Bootstrap,
Expand Down
2 changes: 1 addition & 1 deletion src/uiprotect/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from uuid import UUID

from convertertools import pop_dict_set_if_none, pop_dict_tuple
from propcache import cached_property
from pydantic.v1 import BaseModel
from pydantic.v1.fields import SHAPE_DICT, SHAPE_LIST, PrivateAttr

from .._compat import cached_property
from ..exceptions import BadRequest, ClientError, NotAuthorized
from ..utils import (
asyncio_timeout,
Expand Down
3 changes: 2 additions & 1 deletion src/uiprotect/data/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
from typing import Any, Literal, Optional, TypeVar, Union

from packaging.version import Version as BaseVersion
from propcache import cached_property
from pydantic.v1 import BaseModel, ConstrainedInt
from pydantic.v1.color import Color as BaseColor
from pydantic.v1.types import ConstrainedFloat, ConstrainedStr

from .._compat import cached_property

KT = TypeVar("KT")
VT = TypeVar("VT")

Expand Down
2 changes: 1 addition & 1 deletion src/uiprotect/data/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from typing import TYPE_CHECKING, Any

import orjson
from propcache import cached_property

from .._compat import cached_property
from ..exceptions import WSDecodeError, WSEncodeError
from .types import ProtectWSPayloadFormat

Expand Down

0 comments on commit b37f833

Please sign in to comment.