Skip to content

Commit 5ea53e8

Browse files
committed
mypy
1 parent d27bb10 commit 5ea53e8

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

sentry_sdk/integrations/redis/redis_cluster.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ def _set_async_cluster_db_data(span, async_redis_cluster_instance):
3636
def _set_async_cluster_pipeline_db_data(span, async_redis_cluster_pipeline_instance):
3737
# type: (Span, AsyncClusterPipeline[Any]) -> None
3838
with capture_internal_exceptions():
39-
client = (
40-
getattr(async_redis_cluster_pipeline_instance, "cluster_client", None)
41-
or async_redis_cluster_pipeline_instance._client
42-
) # type: AsyncRedisCluster[Any]
39+
client = getattr(async_redis_cluster_pipeline_instance, "cluster_client", None)
40+
if client is None:
41+
# In older redis-py versions, the AsyncClusterPipeline had a `_client`
42+
# attr but it is private so potentially problematic and mypy does not
43+
# recognize it - see
44+
# https://github.com/redis/redis-py/blame/v5.0.0/redis/asyncio/cluster.py#L1386
45+
client = (
46+
async_redis_cluster_pipeline_instance._client
47+
) # type:ignore[attr-defined]
48+
4349
_set_async_cluster_db_data(
4450
span,
45-
# the AsyncClusterPipeline has always had a `_client` attr but it is private so potentially problematic and mypy
46-
# does not recognize it - see https://github.com/redis/redis-py/blame/v5.0.0/redis/asyncio/cluster.py#L1386
4751
client,
4852
)
4953

0 commit comments

Comments
 (0)