Skip to content

Commit a89f877

Browse files
authored
Merge pull request #21 from wwarne/bump_version
Fix some typing warnings Redis package already has some stubs I mistakenly had used types-redis package which is only for redis-py 4.6
2 parents c950e10 + 52f441e commit a89f877

File tree

4 files changed

+12
-175
lines changed

4 files changed

+12
-175
lines changed

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "dogpile_breaker"
3-
version = "0.13.0"
3+
version = "0.14.0"
44
description = "Cache for Asyncio Applications with Anti-Dogpile Effect"
55
readme = "README.md"
66
authors = [
@@ -32,7 +32,6 @@ dev = [
3232
"pytest>=8.3.4",
3333
"pytest-asyncio>=0.25.3",
3434
"ruff>=0.8.3",
35-
"types-redis>=4.6.0.20241004",
3635
]
3736

3837
[tool.ruff]

src/dogpile_breaker/backends/redis_backend.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ async def aclose(self) -> None:
6666
# https://github.com/redis/redis-py/issues/2995#issuecomment-1764876240
6767
# by default closing redis won't close the connection pool and it could lead
6868
# to problems. So we need to make sure we close the connections.
69-
await self.redis.aclose() # type:ignore[attr-defined]
70-
await self.pool.aclose() # type:ignore[attr-defined]
69+
await self.redis.aclose()
70+
await self.pool.aclose()
7171

7272
async def get_serialized(self, key: str) -> bytes | None:
7373
return cast("bytes | None", await self.redis.get(key))
@@ -122,7 +122,7 @@ def __init__(
122122
"retry_on_error", [RedisConnectionError, RedisTimeoutError, ConnectionRefusedError]
123123
)
124124
self.master_name = master_name
125-
self.sentinel = Sentinel(
125+
self.sentinel = Sentinel( # type:ignore[no-untyped-call]
126126
sentinels=sentinels,
127127
retry=retry,
128128
retry_on_error=retry_on_error,
@@ -143,4 +143,4 @@ async def initialize(self) -> None:
143143
async def aclose(self) -> None:
144144
# then using sentinel.master_for
145145
# The Redis object "owns" the pool so it closes after closing Redis instance
146-
await self.redis.aclose() # type:ignore[attr-defined]
146+
await self.redis.aclose()

src/dogpile_breaker/backends/redis_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Unused: TypeAlias = object
2323

2424

25-
class AsyncRedisClient(Redis): # type:ignore[type-arg]
25+
class AsyncRedisClient(Redis):
2626
# Note - mypy throws error - Call to untyped function "execute_command" in typed context
2727
@override
2828
async def execute_command(self, *args: Any, **options: Any) -> Any:
@@ -37,7 +37,7 @@ async def execute_command(self, *args: Any, **options: Any) -> Any:
3737
raise CacheBackendInteractionError from e
3838

3939

40-
class SentinelBlockingPool(SentinelConnectionPool): # type:ignore[type-arg]
40+
class SentinelBlockingPool(SentinelConnectionPool):
4141
"""
4242
It performs the same function as the default
4343
`redis.asyncio.SentinelConnectionPool` implementation, in that,
@@ -58,22 +58,22 @@ class SentinelBlockingPool(SentinelConnectionPool): # type:ignore[type-arg]
5858

5959
def __init__(self, service_name: str, sentinel_manager: Sentinel, **kwargs: Any) -> None:
6060
self.timeout = kwargs.pop("timeout", 20)
61-
super().__init__(service_name, sentinel_manager, **kwargs)
61+
super().__init__(service_name, sentinel_manager, **kwargs) # type:ignore[no-untyped-call]
6262
self._condition = asyncio.Condition()
6363

64-
async def get_connection(self, command_name: Unused, *keys: Unused, **options: Unused) -> _ConnectionT: # noqa: ARG002
64+
async def get_connection(self, command_name: Any = ..., *keys: Any, **options: Any) -> _ConnectionT: # noqa: ARG002
6565
"""Gets a connection from the pool, blocking until one is available"""
6666
try:
6767
async with self._condition: # noqa: SIM117
6868
async with async_timeout(self.timeout):
69-
await self._condition.wait_for(self.can_get_connection) # type:ignore[attr-defined]
70-
connection = super().get_available_connection() # type:ignore[misc]
69+
await self._condition.wait_for(self.can_get_connection)
70+
connection = super().get_available_connection() # type:ignore[no-untyped-call]
7171
except asyncio.TimeoutError as err:
7272
raise ConnectionError("No connection available.") from err # noqa: EM101, TRY003
7373

7474
# We now perform the connection check outside of the lock.
7575
try:
76-
await self.ensure_connection(connection) # type:ignore[attr-defined]
76+
await self.ensure_connection(connection)
7777
except BaseException:
7878
await self.release(connection)
7979
raise

0 commit comments

Comments
 (0)