Skip to content

Commit f18650f

Browse files
refactor: Remove unused *args and **kwargs from V1 sanitization strategies
Removes unused constructor parameters from store-specific V1 sanitization strategy classes to make the API clearer. These strategies are pre-configured with fixed parameters and don't support customization, so the unused parameters were misleading. Changes: - ElasticsearchV1KeySanitizationStrategy - ElasticsearchV1CollectionSanitizationStrategy - KeyringV1SanitizationStrategy - MemcachedV1KeySanitizationStrategy - MongoDBV1CollectionSanitizationStrategy - WindowsRegistryV1SanitizationStrategy Co-authored-by: William Easton <strawgate@users.noreply.github.com>
1 parent 23c348d commit f18650f

File tree

9 files changed

+14
-17
lines changed

9 files changed

+14
-17
lines changed

key-value/key-value-aio/src/key_value/aio/stores/elasticsearch/store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ def prepare_load(self, data: dict[str, Any]) -> dict[str, Any]:
115115

116116

117117
class ElasticsearchV1KeySanitizationStrategy(AlwaysHashStrategy):
118-
def __init__(self, *args: Any, **kwargs: Any) -> None: # noqa: ARG002
118+
def __init__(self) -> None:
119119
super().__init__(
120120
hash_length=64,
121121
)
122122

123123

124124
class ElasticsearchV1CollectionSanitizationStrategy(HybridSanitizationStrategy):
125-
def __init__(self, *args: Any, **kwargs: Any) -> None: # noqa: ARG002
125+
def __init__(self) -> None:
126126
super().__init__(
127127
replacement_character="_",
128128
max_length=MAX_INDEX_LENGTH,

key-value/key-value-aio/src/key_value/aio/stores/keyring/store.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Python keyring-based key-value store."""
22

3-
from typing import Any
43

54
from key_value.shared.utils.compound import compound_key
65
from key_value.shared.utils.managed_entry import ManagedEntry
@@ -24,7 +23,7 @@
2423

2524

2625
class KeyringV1SanitizationStrategy(HybridSanitizationStrategy):
27-
def __init__(self, *args: Any, **kwargs: Any) -> None: # noqa: ARG002
26+
def __init__(self) -> None:
2827
super().__init__(
2928
replacement_character="_",
3029
max_length=MAX_KEY_COLLECTION_LENGTH,

key-value/key-value-aio/src/key_value/aio/stores/memcached/store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Sequence
2-
from typing import Any, overload
2+
from typing import overload
33

44
from key_value.shared.utils.compound import compound_key
55
from key_value.shared.utils.managed_entry import ManagedEntry
@@ -18,7 +18,7 @@
1818

1919

2020
class MemcachedV1KeySanitizationStrategy(HashExcessLengthStrategy):
21-
def __init__(self, *args: Any, **kwargs: Any) -> None: # noqa: ARG002
21+
def __init__(self) -> None:
2222
super().__init__(max_length=MAX_KEY_LENGTH)
2323

2424

key-value/key-value-aio/src/key_value/aio/stores/mongodb/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def prepare_load(self, data: dict[str, Any]) -> dict[str, Any]:
9090

9191

9292
class MongoDBV1CollectionSanitizationStrategy(HybridSanitizationStrategy):
93-
def __init__(self, *args: Any, **kwargs: Any) -> None: # noqa: ARG002
93+
def __init__(self) -> None:
9494
super().__init__(
9595
replacement_character="_",
9696
max_length=MAX_COLLECTION_LENGTH,

key-value/key-value-aio/src/key_value/aio/stores/windows_registry/store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Windows Registry-based key-value store."""
22

3-
from typing import Any, Literal
3+
from typing import Literal
44
from winreg import HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE
55

66
from key_value.shared.utils.managed_entry import ManagedEntry
@@ -26,7 +26,7 @@
2626

2727

2828
class WindowsRegistryV1SanitizationStrategy(HybridSanitizationStrategy):
29-
def __init__(self, *args: Any, **kwargs: Any) -> None: # noqa: ARG002
29+
def __init__(self) -> None:
3030
super().__init__(
3131
max_length=MAX_KEY_COLLECTION_LENGTH,
3232
allowed_characters=ALLOWED_KEY_COLLECTION_CHARACTERS,

key-value/key-value-sync/src/key_value/sync/code_gen/stores/elasticsearch/store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ def prepare_load(self, data: dict[str, Any]) -> dict[str, Any]:
9696

9797

9898
class ElasticsearchV1KeySanitizationStrategy(AlwaysHashStrategy):
99-
def __init__(self, *args: Any, **kwargs: Any) -> None:
99+
def __init__(self) -> None:
100100
super().__init__(hash_length=64)
101101

102102

103103
class ElasticsearchV1CollectionSanitizationStrategy(HybridSanitizationStrategy):
104-
def __init__(self, *args: Any, **kwargs: Any) -> None:
104+
def __init__(self) -> None:
105105
super().__init__(
106106
replacement_character="_",
107107
max_length=MAX_INDEX_LENGTH,

key-value/key-value-sync/src/key_value/sync/code_gen/stores/keyring/store.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# DO NOT CHANGE! Change the original file instead.
44
"""Python keyring-based key-value store."""
55

6-
from typing import Any
7-
86
from key_value.shared.utils.compound import compound_key
97
from key_value.shared.utils.managed_entry import ManagedEntry
108
from key_value.shared.utils.sanitization import HybridSanitizationStrategy, PassthroughStrategy, SanitizationStrategy
@@ -27,7 +25,7 @@
2725

2826

2927
class KeyringV1SanitizationStrategy(HybridSanitizationStrategy):
30-
def __init__(self, *args: Any, **kwargs: Any) -> None:
28+
def __init__(self) -> None:
3129
super().__init__(
3230
replacement_character="_", max_length=MAX_KEY_COLLECTION_LENGTH, allowed_characters=ALLOWED_KEY_COLLECTION_CHARACTERS
3331
)

key-value/key-value-sync/src/key_value/sync/code_gen/stores/mongodb/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def prepare_load(self, data: dict[str, Any]) -> dict[str, Any]:
9292

9393

9494
class MongoDBV1CollectionSanitizationStrategy(HybridSanitizationStrategy):
95-
def __init__(self, *args: Any, **kwargs: Any) -> None:
95+
def __init__(self) -> None:
9696
super().__init__(replacement_character="_", max_length=MAX_COLLECTION_LENGTH, allowed_characters=COLLECTION_ALLOWED_CHARACTERS)
9797

9898

key-value/key-value-sync/src/key_value/sync/code_gen/stores/windows_registry/store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# DO NOT CHANGE! Change the original file instead.
44
"""Windows Registry-based key-value store."""
55

6-
from typing import Any, Literal
6+
from typing import Literal
77
from winreg import HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE
88

99
from key_value.shared.utils.managed_entry import ManagedEntry
@@ -35,7 +35,7 @@
3535

3636

3737
class WindowsRegistryV1SanitizationStrategy(HybridSanitizationStrategy):
38-
def __init__(self, *args: Any, **kwargs: Any) -> None:
38+
def __init__(self) -> None:
3939
super().__init__(max_length=MAX_KEY_COLLECTION_LENGTH, allowed_characters=ALLOWED_KEY_COLLECTION_CHARACTERS)
4040

4141

0 commit comments

Comments
 (0)