]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Fix conditional imports for pyright (#1839)
authorRobert Craigie <robertcraigie30@gmail.com>
Fri, 3 Sep 2021 13:51:42 +0000 (14:51 +0100)
committerGitHub <noreply@github.com>
Fri, 3 Sep 2021 13:51:42 +0000 (14:51 +0100)
httpx/_compat.py

index 15e915a9c9fec5ee6bf61f72c98969faadda58e2..ed61e98f60960090f62ef49585987198be34252d 100644 (file)
@@ -7,9 +7,9 @@ import sys
 
 # `contextlib.asynccontextmanager` exists from Python 3.7 onwards.
 # For 3.6 we require the `async_generator` package for a backported version.
-try:
+if sys.version_info >= (3, 7):
     from contextlib import asynccontextmanager  # type: ignore
-except ImportError:
+else:
     from async_generator import asynccontextmanager  # type: ignore # noqa
 
 # Brotli support is optional