From 714314e89f92902962372cdcfeae11a69af608f9 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Wed, 22 Apr 2026 14:38:27 +0200 Subject: [PATCH] fix: deprecate httpx ref https://github.com/python-caldav/caldav/issues/611#issuecomment-4278875543 - the httpx project seems dead, killed by drama and intrigues. The abrupt closing of the primary channels for community feedback is even flagged as a supply chain risk on Reddit --- caldav/async_davclient.py | 48 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/caldav/async_davclient.py b/caldav/async_davclient.py index d7630e14..f21e5f88 100644 --- a/caldav/async_davclient.py +++ b/caldav/async_davclient.py @@ -18,43 +18,43 @@ from caldav.calendarobjectresource import CalendarObjectResource, Event, Todo from caldav.collection import Calendar, Principal -# Try httpx first (preferred), fall back to niquests +# Try niquests first (preferred), fall back to httpx _USE_HTTPX = False _USE_NIQUESTS = False _H2_AVAILABLE = False try: - import httpx + import niquests + from niquests import AsyncSession + from niquests.structures import CaseInsensitiveDict - _USE_HTTPX = True - # Check if h2 is available for HTTP/2 support - try: - import h2 # noqa: F401 + _USE_NIQUESTS = True +except ImportError: + pass - _H2_AVAILABLE = True - except ImportError: - pass +if not _USE_NIQUESTS: + try: + import httpx - class _HttpxBearerAuth(httpx.Auth): - """httpx-compatible bearer token auth.""" + _USE_HTTPX = True + # Check if h2 is available for HTTP/2 support + try: + import h2 # noqa: F401 - def __init__(self, password: str) -> None: - self.password = password + _H2_AVAILABLE = True + except ImportError: + pass - def auth_flow(self, request): - request.headers["Authorization"] = f"Bearer {self.password}" - yield request + class _HttpxBearerAuth(httpx.Auth): + """httpx-compatible bearer token auth.""" -except ImportError: - pass + def __init__(self, password: str) -> None: + self.password = password -if not _USE_HTTPX: - try: - import niquests - from niquests import AsyncSession - from niquests.structures import CaseInsensitiveDict + def auth_flow(self, request): + request.headers["Authorization"] = f"Bearer {self.password}" + yield request - _USE_NIQUESTS = True except ImportError: pass