Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Atry authored Apr 10, 2024
2 parents 79b48e6 + 4576c4f commit 13d770c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions cached_classproperty/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import importlib.metadata
from _thread import RLock # type: ignore
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Optional

__version__ = importlib.metadata.version("cached_classproperty")

Expand All @@ -16,12 +16,12 @@
T = TypeVar("T")

def cached_staticproperty(
func: Callable[[], T], attrname: str | None = None
func: Callable[[], T], attrname: Optional[str] = None
) -> T:
...

def cached_classproperty(
func: Callable[[type], T], attrname: str | None = None
func: Callable[[type], T], attrname: Optional[str] = None
) -> T:
...

Expand All @@ -30,7 +30,7 @@ def cached_classproperty(
class cached_staticproperty:
__slots__ = ("func", "attrname", "lock")

def __init__(self, func, attrname: str | None = None):
def __init__(self, func, attrname: Optional[str] = None):
self.func = func
self.attrname = attrname
self.lock = RLock()
Expand Down Expand Up @@ -71,7 +71,7 @@ def __get__(self, instance, owner=None):
class cached_classproperty:
__slots__ = ("func", "attrname", "lock", "owner", "_cached_value", "_weak_dict")

def __init__(self, func, attrname: str | None = None):
def __init__(self, func, attrname: Optional[str] = None):
self.func = func
self.attrname = attrname
self.lock = RLock()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cached_classproperty"
version = "1.0.0"
version = "1.0.1"
description = ""
authors = ["Stanislav Zmiev <[email protected]>"]
license = "MIT"
Expand Down
5 changes: 4 additions & 1 deletion tests/test_classproperty.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,19 @@ class Superclass:
@cached_classproperty
def my_cached_classproperty(cls):
return ("Superclass",)

@classmethod
def my_classmethod(cls):
return ("Superclass",)


class Subclass1(Superclass):
@cached_classproperty
def my_cached_classproperty(cls):
return (
*super().my_cached_classproperty,
"Subclass1",
)

@classmethod
def my_classmethod(cls):
return (
Expand All @@ -181,6 +182,7 @@ def my_cached_classproperty(cls):
*super().my_cached_classproperty,
"Subclass2",
)

@classmethod
def my_classmethod(cls):
return (
Expand All @@ -195,6 +197,7 @@ def my_cached_classproperty(cls):
*super().my_cached_classproperty,
"Finalclass",
)

@classmethod
def my_classmethod(cls):
return (
Expand Down

0 comments on commit 13d770c

Please sign in to comment.