Skip to content

Commit 2b2ec29

Browse files
committed
chore: add @OverRide decorator to serialization methods
1 parent b48ef01 commit 2b2ec29

5 files changed

Lines changed: 18 additions & 3 deletions

File tree

cachium/serializers/_md5.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import hashlib
22
from typing import Any
33

4+
from typing_extensions import override
5+
46
from ._abc import Serializer
57

68

@@ -12,7 +14,8 @@ class Md5Serializer(Serializer):
1214
across different Python processes and sessions.
1315
"""
1416

17+
@override
1518
@classmethod
16-
def serialize(cls, value: Any) -> str: # noqa: ANN401
19+
def serialize(cls, value: Any) -> str:
1720
"""Convert value to string using MD5 hash."""
1821
return hashlib.md5(str(value).encode(), usedforsecurity=False).hexdigest()

cachium/serializers/_repr.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import Any
22

3+
from typing_extensions import override
4+
35
from ._abc import Serializer
46

57

@@ -23,7 +25,8 @@ class ReprSerializer(Serializer):
2325
```
2426
"""
2527

28+
@override
2629
@classmethod
27-
def serialize(cls, value: Any) -> str: # noqa: ANN401
30+
def serialize(cls, value: Any) -> str:
2831
"""Convert value to string."""
2932
return repr(value)

cachium/serializers/_std_hash.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from collections.abc import Hashable
22

3+
from typing_extensions import override
4+
35
from ._abc import Serializer
46

57

@@ -34,6 +36,7 @@ class StdHashSerializer(Serializer):
3436
3537
"""
3638

39+
@override
3740
@classmethod
3841
def serialize(cls, value: Hashable) -> str:
3942
"""Convert value to string."""

cachium/serializers/_str.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import Any
22

3+
from typing_extensions import override
4+
35
from ._abc import Serializer
46

57

@@ -24,7 +26,8 @@ class StrSerializer(Serializer):
2426
```
2527
"""
2628

29+
@override
2730
@classmethod
28-
def serialize(cls, value: Any) -> str: # noqa: ANN401
31+
def serialize(cls, value: Any) -> str:
2932
"""Convert value to string."""
3033
return str(value)

cachium/storages/_abc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from abc import ABC, abstractmethod
44
from typing import TYPE_CHECKING, Generic, TypeVar
55

6+
from typing_extensions import override
7+
68
if TYPE_CHECKING:
79
from datetime import timedelta
810
from types import TracebackType
@@ -20,6 +22,7 @@ class Result(Generic[TValue]):
2022
def __init__(self, value: TValue) -> None:
2123
self._value = value
2224

25+
@override
2326
def __repr__(self) -> str:
2427
return f"Result({self._value!r})"
2528

0 commit comments

Comments
 (0)