From d63eedd72954f5864fb12df8d4a2c8201b03482c Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 12 Nov 2021 10:36:10 +0000 Subject: [PATCH] Fix import issues. Closes #426 --- httpcore/_async/__init__.py | 8 +++++++- httpcore/_sync/__init__.py | 8 +++++++- setup.py | 7 ++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/httpcore/_async/__init__.py b/httpcore/_async/__init__.py index f089fab8..a230ebeb 100644 --- a/httpcore/_async/__init__.py +++ b/httpcore/_async/__init__.py @@ -7,7 +7,13 @@ try: from .http2 import AsyncHTTP2Connection except ImportError: # pragma: nocover - pass + + class AsyncHTTP2Connection: # type: ignore + def __init__(self, *args, **kwargs) -> None: # type: ignore + raise RuntimeError( + "Attempted to use http2 support, but the `h2` package is not " + "installed. Use 'pip install httpcore[http2]'." + ) __all__ = [ diff --git a/httpcore/_sync/__init__.py b/httpcore/_sync/__init__.py index 6469b1a9..73de5c1b 100644 --- a/httpcore/_sync/__init__.py +++ b/httpcore/_sync/__init__.py @@ -7,7 +7,13 @@ try: from .http2 import HTTP2Connection except ImportError: # pragma: nocover - pass + + class HTTP2Connection: # type: ignore + def __init__(self, *args, **kwargs) -> None: # type: ignore + raise RuntimeError( + "Attempted to use http2 support, but the `h2` package is not " + "installed. Use 'pip install httpcore[http2]'." + ) __all__ = [ diff --git a/setup.py b/setup.py index 3f5648d1..c0d0a448 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,12 @@ def get_packages(package): packages=get_packages("httpcore"), include_package_data=True, zip_safe=False, - install_requires=["h11>=0.11,<0.13", "sniffio==1.*", "anyio==3.*"], + install_requires=[ + "h11>=0.11,<0.13", + "sniffio==1.*", + "anyio==3.*", + "certifi", + ], extras_require={ "http2": ["h2>=3,<5"], },