Skip to content

Commit a967d64

Browse files
committed
fixed some type hints
1 parent c4abd65 commit a967d64

File tree

3 files changed

+45
-47
lines changed

3 files changed

+45
-47
lines changed

django_valkey/async_cache/client/default.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ async def aadd(
124124
self,
125125
key,
126126
value,
127-
timeout: float | int | None = DEFAULT_TIMEOUT,
127+
timeout: int | None = DEFAULT_TIMEOUT,
128128
version: int | None = None,
129129
client: AValkey | Any | None = None,
130130
) -> bool:
@@ -230,7 +230,7 @@ async def aget_lock(
230230
self,
231231
key,
232232
version: int | None = None,
233-
timeout: float | int | None = None,
233+
timeout: float | None = None,
234234
sleep: float = 0.1,
235235
blocking: bool = True,
236236
blocking_timeout: float | None = None,
@@ -407,7 +407,7 @@ async def aget_many(
407407
async def aset_many(
408408
self,
409409
data: dict,
410-
timeout: float | int | None = None,
410+
timeout: int | None = None,
411411
version: int | None = None,
412412
client: AValkey | Any | None = None,
413413
) -> None:
@@ -975,7 +975,7 @@ async def _aclose(self) -> None:
975975
async def atouch(
976976
self,
977977
key,
978-
timeout: float | int | None = DEFAULT_TIMEOUT,
978+
timeout: int | None = DEFAULT_TIMEOUT,
979979
version: int | None = None,
980980
client: AValkey | Any | None = None,
981981
) -> bool:

django_valkey/client/default.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def set(
2222
self,
2323
key: KeyT,
2424
value: EncodableT,
25-
timeout: int | float | None = DEFAULT_TIMEOUT,
25+
timeout: int | None = DEFAULT_TIMEOUT,
2626
version: int | None = None,
2727
client: Valkey | Any | None = None,
2828
nx: bool = False,
@@ -130,7 +130,7 @@ def add(
130130
self,
131131
key: KeyT,
132132
value: EncodableT,
133-
timeout: float | None = DEFAULT_TIMEOUT,
133+
timeout: int | None = DEFAULT_TIMEOUT,
134134
version: int | None = None,
135135
client: Valkey | Any | None = None,
136136
) -> bool:
@@ -421,7 +421,7 @@ def get_many(
421421
def set_many(
422422
self,
423423
data: dict[KeyT, EncodableT],
424-
timeout: float | None = DEFAULT_TIMEOUT,
424+
timeout: int | None = DEFAULT_TIMEOUT,
425425
version: int | None = None,
426426
client: Valkey | Any | None = None,
427427
) -> None:
@@ -948,7 +948,7 @@ def _close(self) -> None:
948948
def touch(
949949
self,
950950
key: KeyT,
951-
timeout: float | None = DEFAULT_TIMEOUT,
951+
timeout: int | None = DEFAULT_TIMEOUT,
952952
version: int | None = None,
953953
client: Valkey | Any | None = None,
954954
) -> bool:

django_valkey/client/sharded.py

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ def add(
5252
self,
5353
key: KeyT,
5454
value: EncodableT,
55-
timeout: float | None = DEFAULT_TIMEOUT,
55+
timeout: int | None = DEFAULT_TIMEOUT,
5656
version: int | None = None,
57-
client: Valkey | Any | None = None,
57+
client: Valkey | None = None,
5858
) -> bool:
5959
if client is None:
6060
key = self.make_key(key, version=version)
@@ -69,7 +69,7 @@ def get(
6969
key: KeyT,
7070
default: Any | None = None,
7171
version: int | None = None,
72-
client: Valkey | Any | None = None,
72+
client: Valkey | None = None,
7373
) -> Any:
7474
if client is None:
7575
key = self.make_key(key, version=version)
@@ -81,7 +81,7 @@ def get_many(
8181
self,
8282
keys: KeyT,
8383
version: int | None = None,
84-
_client: Valkey | Any | None = None,
84+
_client: Valkey | None = None,
8585
) -> dict:
8686
if not keys:
8787
return {}
@@ -108,9 +108,9 @@ def set(
108108
self,
109109
key: KeyT,
110110
value: EncodableT,
111-
timeout: int | float | None = DEFAULT_TIMEOUT,
111+
timeout: int | None = DEFAULT_TIMEOUT,
112112
version: int | None = None,
113-
client: Valkey | Any | None = None,
113+
client: Valkey | None = None,
114114
nx: bool = False,
115115
xx: bool = False,
116116
) -> bool:
@@ -134,9 +134,9 @@ def set(
134134
def set_many(
135135
self,
136136
data: dict[KeyT, EncodableT],
137-
timeout: float | None = DEFAULT_TIMEOUT,
137+
timeout: int | None = DEFAULT_TIMEOUT,
138138
version: int | None = None,
139-
client: Valkey | Any | None = None,
139+
client: Valkey | None = None,
140140
) -> None:
141141
"""
142142
Set a bunch of values in the cache at once from a dict of key/value
@@ -152,7 +152,7 @@ def mset(self, *args, **kwargs):
152152
raise NotImplementedError
153153

154154
def has_key(
155-
self, key: KeyT, version: int | None = None, client: Valkey | Any | None = None
155+
self, key: KeyT, version: int | None = None, client: Valkey | None = None
156156
) -> bool:
157157
"""
158158
Test if key exists.
@@ -173,7 +173,7 @@ def delete(
173173
key: KeyT,
174174
version: int | None = None,
175175
prefix: str | None = None,
176-
client: Valkey | Any | None = None,
176+
client: Valkey | None = None,
177177
) -> int:
178178
if client is None:
179179
key = self.make_key(key, version=version)
@@ -182,7 +182,7 @@ def delete(
182182
return super().delete(key=key, version=version, client=client)
183183

184184
def ttl(
185-
self, key: KeyT, version: int | None = None, client: Valkey | Any | None = None
185+
self, key: KeyT, version: int | None = None, client: Valkey | None = None
186186
) -> int | None:
187187
"""
188188
Executes TTL valkey command and return the "time-to-live" of specified key.
@@ -196,7 +196,7 @@ def ttl(
196196
return super().ttl(key=key, version=version, client=client)
197197

198198
def pttl(
199-
self, key: KeyT, version: int | None = None, client: Valkey | Any | None = None
199+
self, key: KeyT, version: int | None = None, client: Valkey | None = None
200200
) -> int | None:
201201
"""
202202
Executes PTTL valkey command and return the "time-to-live" of specified key
@@ -210,7 +210,7 @@ def pttl(
210210
return super().pttl(key=key, version=version, client=client)
211211

212212
def persist(
213-
self, key: KeyT, version: int | None = None, client: Valkey | Any | None = None
213+
self, key: KeyT, version: int | None = None, client: Valkey | None = None
214214
) -> bool:
215215
if client is None:
216216
key = self.make_key(key, version=version)
@@ -223,7 +223,7 @@ def expire(
223223
key: KeyT,
224224
timeout: int | timedelta,
225225
version: int | None = None,
226-
client: Valkey | Any | None = None,
226+
client: Valkey | None = None,
227227
) -> bool:
228228
if client is None:
229229
key = self.make_key(key, version=version)
@@ -236,7 +236,7 @@ def pexpire(
236236
key: KeyT,
237237
timeout: int | timedelta,
238238
version: int | None = None,
239-
client: Valkey | Any | None = None,
239+
client: Valkey | None = None,
240240
) -> bool:
241241
if client is None:
242242
key = self.make_key(key, version=version)
@@ -249,7 +249,7 @@ def pexpire_at(
249249
key: KeyT,
250250
when: datetime | int,
251251
version: int | None = None,
252-
client: Valkey | Any | None = None,
252+
client: Valkey | None = None,
253253
) -> bool:
254254
"""
255255
Set an expiry flag on a ``key`` to ``when`` on a shard client.
@@ -267,7 +267,7 @@ def expire_at(
267267
key: KeyT,
268268
when: datetime | int,
269269
version: int | None = None,
270-
client: Valkey | Any | None = None,
270+
client: Valkey | None = None,
271271
) -> bool:
272272
"""
273273
Set an expiry flag on a ``key`` to ``when`` on a shard client.
@@ -310,9 +310,7 @@ def get_lock(
310310
# TODO: delete in future.
311311
lock = get_lock
312312

313-
def delete_many(
314-
self, keys, version=None, _client: Valkey | Any | None = None
315-
) -> int:
313+
def delete_many(self, keys, version=None, _client: Valkey | None = None) -> int:
316314
"""
317315
Remove multiple keys at once.
318316
"""
@@ -327,7 +325,7 @@ def incr_version(
327325
key: KeyT,
328326
delta: int = 1,
329327
version: int | None = None,
330-
client: Valkey | Any | None = None,
328+
client: Valkey | None = None,
331329
) -> int:
332330
if client is None:
333331
key = self.make_key(key, version=version)
@@ -345,7 +343,7 @@ def incr(
345343
key: KeyT,
346344
delta: int = 1,
347345
version: int | None = None,
348-
client: Valkey | Any | None = None,
346+
client: Valkey | None = None,
349347
**kwargs,
350348
) -> int:
351349
if client is None:
@@ -359,7 +357,7 @@ def decr(
359357
key: KeyT,
360358
delta: int = 1,
361359
version: int | None = None,
362-
client: Valkey | Any | None = None,
360+
client: Valkey | None = None,
363361
) -> int:
364362
if client is None:
365363
key = self.make_key(key, version=version)
@@ -371,7 +369,7 @@ def iter_keys(
371369
self,
372370
search: str,
373371
itersize: int | None = None,
374-
client: Valkey | Any | None = None,
372+
client: Valkey | None = None,
375373
version: int | None = None,
376374
):
377375
"""Not Implemented"""
@@ -382,7 +380,7 @@ def keys(
382380
self,
383381
search: str,
384382
version: int | None = None,
385-
client: Valkey | Any | None = None,
383+
client: Valkey | None = None,
386384
) -> list[str]:
387385
pattern = self.make_pattern(search, version=version)
388386
keys = []
@@ -400,7 +398,7 @@ def delete_pattern(
400398
self,
401399
pattern: str,
402400
version: int | None = None,
403-
client: Valkey | Any | None = None,
401+
client: Valkey | None = None,
404402
itersize: int | None = None,
405403
prefix: str | None = None,
406404
) -> int:
@@ -429,9 +427,9 @@ def _close(self) -> None:
429427
def touch(
430428
self,
431429
key: KeyT,
432-
timeout: float | None = DEFAULT_TIMEOUT,
430+
timeout: int | None = DEFAULT_TIMEOUT,
433431
version: int | None = None,
434-
client: Valkey | Any | None = None,
432+
client: Valkey | None = None,
435433
) -> bool:
436434
if client is None:
437435
key = self.make_key(key, version=version)
@@ -448,7 +446,7 @@ def sadd(
448446
key: KeyT,
449447
*values: Any,
450448
version: int | None = None,
451-
client: Valkey | Any | None = None,
449+
client: Valkey | None = None,
452450
) -> int:
453451
if client is None:
454452
key = self.make_key(key, version=version)
@@ -459,7 +457,7 @@ def scard(
459457
self,
460458
key: KeyT,
461459
version: int | None = None,
462-
client: Valkey | Any | None = None,
460+
client: Valkey | None = None,
463461
) -> int:
464462
if client is None:
465463
key = self.make_key(key, version=version)
@@ -470,7 +468,7 @@ def smembers(
470468
self,
471469
key: KeyT,
472470
version: int | None = None,
473-
client: Valkey | Any | None = None,
471+
client: Valkey | None = None,
474472
return_set: bool = True,
475473
) -> builtins.set[Any] | list[Any]:
476474
if client is None:
@@ -486,7 +484,7 @@ def smove(
486484
destination: KeyT,
487485
member: Any,
488486
version: int | None = None,
489-
client: Valkey | Any | None = None,
487+
client: Valkey | None = None,
490488
) -> bool:
491489
if client is None:
492490
source = self.make_key(source, version=version)
@@ -506,7 +504,7 @@ def srem(
506504
key: KeyT,
507505
*members,
508506
version: int | None = None,
509-
client: Valkey | Any | None = None,
507+
client: Valkey | None = None,
510508
) -> int:
511509
if client is None:
512510
key = self.make_key(key, version=version)
@@ -520,7 +518,7 @@ def sscan(
520518
match: str | None = None,
521519
count: int = 10,
522520
version: int | None = None,
523-
client: Valkey | Any | None = None,
521+
client: Valkey | None = None,
524522
return_set: bool = True,
525523
) -> tuple[int, builtins.set[Any]] | tuple[int, list[Any]]:
526524
if client is None:
@@ -542,7 +540,7 @@ def sscan_iter(
542540
match: str | None = None,
543541
count: int = 10,
544542
version: int | None = None,
545-
client: Valkey | Any | Any | None = None,
543+
client: Valkey | None = None,
546544
) -> Iterator[Any]:
547545
if client is None:
548546
key = self.make_key(key, version=version)
@@ -556,7 +554,7 @@ def srandmember(
556554
key: KeyT,
557555
count: int | None = None,
558556
version: int | None = None,
559-
client: Valkey | Any | None = None,
557+
client: Valkey | None = None,
560558
return_set: bool = True,
561559
) -> builtins.set | list | Any:
562560
if client is None:
@@ -571,7 +569,7 @@ def sismember(
571569
key: KeyT,
572570
member: Any,
573571
version: int | None = None,
574-
client: Valkey | Any | None = None,
572+
client: Valkey | None = None,
575573
) -> bool:
576574
if client is None:
577575
key = self.make_key(key, version=version)
@@ -583,7 +581,7 @@ def spop(
583581
key: KeyT,
584582
count: int | None = None,
585583
version: int | None = None,
586-
client: Valkey | Any | None = None,
584+
client: Valkey | None = None,
587585
return_set: bool = True,
588586
) -> builtins.set | list | Any:
589587
if client is None:
@@ -598,7 +596,7 @@ def smismember(
598596
key: KeyT,
599597
*members,
600598
version: int | None = None,
601-
client: Valkey | Any | None = None,
599+
client: Valkey | None = None,
602600
) -> list[bool]:
603601
if client is None:
604602
key = self.make_key(key, version=version)

0 commit comments

Comments
 (0)