diff --git a/ddtrace/contrib/redis/patch.py b/ddtrace/contrib/redis/patch.py index da088659b23..eeca1b96fa7 100644 --- a/ddtrace/contrib/redis/patch.py +++ b/ddtrace/contrib/redis/patch.py @@ -1,4 +1,5 @@ import redis +from six import PY3 from ddtrace import config from ddtrace.vendor import wrapt @@ -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 diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 1de25b828c5..88fe2a50740 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -108,6 +108,7 @@ mongoengine multiline multiprocess multithreaded +mypy mysql mysqlclient mysqldb diff --git a/releasenotes/notes/fix-mypy-py2-redis-4c8d3b4e461c6074.yaml b/releasenotes/notes/fix-mypy-py2-redis-4c8d3b4e461c6074.yaml new file mode 100644 index 00000000000..3eb2c42ab4d --- /dev/null +++ b/releasenotes/notes/fix-mypy-py2-redis-4c8d3b4e461c6074.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + mypy: Avoid parsing redis asyncio files when type checking Python 2