Skip to content

Commit 91e891a

Browse files
committed
fix: deprecate httpx
ref #611 (comment) - 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
1 parent f76d107 commit 91e891a

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

caldav/async_davclient.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,43 @@
1818
from caldav.calendarobjectresource import CalendarObjectResource, Event, Todo
1919
from caldav.collection import Calendar, Principal
2020

21-
# Try httpx first (preferred), fall back to niquests
21+
# Try niquests first (preferred), fall back to httpx
2222
_USE_HTTPX = False
2323
_USE_NIQUESTS = False
2424
_H2_AVAILABLE = False
2525

2626
try:
27-
import httpx
27+
import niquests
28+
from niquests import AsyncSession
29+
from niquests.structures import CaseInsensitiveDict
2830

29-
_USE_HTTPX = True
30-
# Check if h2 is available for HTTP/2 support
31-
try:
32-
import h2 # noqa: F401
31+
_USE_NIQUESTS = True
32+
except ImportError:
33+
pass
3334

34-
_H2_AVAILABLE = True
35-
except ImportError:
36-
pass
35+
if not _USE_NIQUESTS:
36+
try:
37+
import httpx
3738

38-
class _HttpxBearerAuth(httpx.Auth):
39-
"""httpx-compatible bearer token auth."""
39+
_USE_HTTPX = True
40+
# Check if h2 is available for HTTP/2 support
41+
try:
42+
import h2 # noqa: F401
4043

41-
def __init__(self, password: str) -> None:
42-
self.password = password
44+
_H2_AVAILABLE = True
45+
except ImportError:
46+
pass
4347

44-
def auth_flow(self, request):
45-
request.headers["Authorization"] = f"Bearer {self.password}"
46-
yield request
48+
class _HttpxBearerAuth(httpx.Auth):
49+
"""httpx-compatible bearer token auth."""
4750

48-
except ImportError:
49-
pass
51+
def __init__(self, password: str) -> None:
52+
self.password = password
5053

51-
if not _USE_HTTPX:
52-
try:
53-
import niquests
54-
from niquests import AsyncSession
55-
from niquests.structures import CaseInsensitiveDict
54+
def auth_flow(self, request):
55+
request.headers["Authorization"] = f"Bearer {self.password}"
56+
yield request
5657

57-
_USE_NIQUESTS = True
5858
except ImportError:
5959
pass
6060

0 commit comments

Comments
 (0)