Skip to content

Async client: RFC 6764 discovery needs a sync HTTP library #860

Open

Description

@tobixen

Disclaimer: AI-generated text below the line, generated by Claude Opus 5.5, from the prompt(s):

merge #855 and #856
Open a github issue [for the problem found while fixing the CI that blocked those PRs]


caldav/discovery.py imports the sync HTTP library at module level (from caldav.lib.http_sync import requests, line 47) and makes the .well-known lookup with requests.get(). The async client uses it too: get_davclient() in caldav.async_davclient runs RFC 6764 discovery in a worker thread. So an install with only an async library (httpx, httpxyz or httpx2) and neither niquests nor requests raises ImportError: caldav needs an HTTP library for sync communication ... as soon as discovery is reached, although no sync client is in use.

Today it is hidden because niquests is a hard dependency. It matters once that changes (the v4.0 plan in pyproject.toml), and it keeps the CI fallback jobs from testing a truly async-only install: they now install requests explicitly (#857). It surfaced when Radicale 3.9.1 stopped pulling in requests, and test_get_davclient_discovers_off_the_event_loop failed in the async fallback jobs.

Possible fixes:

  • import the sync library lazily inside the function that does the HTTP lookup, and let the async path do that lookup with its own library;
  • or do the small .well-known GET with the standard library (urllib.request), so discovery needs no HTTP library at all.

Done when an async (httpx2 fallback)-style CI job runs without requests installed and the discovery test passes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions