Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Improve handling broken environment with a graceful error #110

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release History
===============

3.6.1 (2024-04-21)
------------------

**Fixed**
- Handling broken environments with a graceful exception with a detailed error message.

3.6.0 (2024-04-20)
------------------

Expand Down
4 changes: 2 additions & 2 deletions src/niquests/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
__url__: str = "https://niquests.readthedocs.io"

__version__: str
__version__ = "3.6.0"
__version__ = "3.6.1"

__build__: int = 0x030600
__build__: int = 0x030601
__author__: str = "Kenneth Reitz"
__author_email__: str = "[email protected]"
__license__: str = "Apache-2.0"
Expand Down
16 changes: 15 additions & 1 deletion src/niquests/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,21 @@
except ImportError:
urllib3 = None # type: ignore[assignment]

T = typing.TypeVar("T", urllib3.Timeout, urllib3.Retry)

if (urllib3 is None and urllib3_future is None) or (
HAS_LEGACY_URLLIB3 and urllib3_future is None
):
raise RuntimeError(
"This is awkward but your environment is missing urllib3-future. "
"Your environment seems broken. "
"You may fix this issue by running `python -m pip install niquests -U` "
"to force reinstall its dependencies."
)

if urllib3 is not None:
T = typing.TypeVar("T", urllib3.Timeout, urllib3.Retry)
else:
T = typing.TypeVar("T", urllib3_future.Timeout, urllib3_future.Retry) # type: ignore


def urllib3_ensure_type(o: T) -> T:
Expand Down
Loading