Skip to content

Commit

Permalink
fix(mypy): avoid parsing redis asyncio files with Python 2 (#3868) (#…
Browse files Browse the repository at this point in the history
…3906)

## Description

Fixes #3845

Co-authored-by: Tahir H. Butt <tahir.butt@datadoghq.com>
  • Loading branch information
mergify[bot] and majorgreys committed Jul 5, 2022
1 parent 7895a47 commit d370b73
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ddtrace/contrib/redis/patch.py
@@ -1,4 +1,5 @@
import redis
from six import PY3

from ddtrace import config
from ddtrace.vendor import wrapt
Expand Down Expand Up @@ -36,7 +37,8 @@ def patch():
_w("redis", "Redis.pipeline", traced_pipeline)
_w("redis.client", "Pipeline.execute", traced_execute_pipeline)
_w("redis.client", "Pipeline.immediate_execute_command", traced_execute_command)
if redis.VERSION >= (4, 2, 0):
# Avoid mypy invalid syntax errors when parsing Python 2 files
if PY3 and redis.VERSION >= (4, 2, 0):
from .asyncio_patch import traced_async_execute_command
from .asyncio_patch import traced_async_execute_pipeline

Expand Down
1 change: 1 addition & 0 deletions docs/spelling_wordlist.txt
Expand Up @@ -108,6 +108,7 @@ mongoengine
multiline
multiprocess
multithreaded
mypy
mysql
mysqlclient
mysqldb
Expand Down
4 changes: 4 additions & 0 deletions releasenotes/notes/fix-mypy-py2-redis-4c8d3b4e461c6074.yaml
@@ -0,0 +1,4 @@
---
fixes:
- |
mypy: Avoid parsing redis asyncio files when type checking Python 2

0 comments on commit d370b73

Please sign in to comment.