Skip to content

fix: make deprecated Client initializer backward-compatible#160

Open
shuofengzhang wants to merge 1 commit intotavily-ai:masterfrom
shuofengzhang:fix/deprecated-client-init-kwargs
Open

fix: make deprecated Client initializer backward-compatible#160
shuofengzhang wants to merge 1 commit intotavily-ai:masterfrom
shuofengzhang:fix/deprecated-client-init-kwargs

Conversation

@shuofengzhang
Copy link

@shuofengzhang shuofengzhang commented Mar 6, 2026

What changed

  • Fixed the deprecated Client initializer so it correctly forwards parameters to TavilyClient.
  • Added backward-compatible handling for three call styles:
    • Client(api_key="...")
    • Client({"api_key": "..."})
    • Client("...")
  • Added regression tests covering keyword-arg and legacy-dict initialization paths.

Why

  • The deprecated Client class currently passes a single positional argument directly to TavilyClient, which can mis-handle initialization data (for example, passing a dict as the API key).
  • This change preserves backwards compatibility while ensuring deprecated usage remains functional and predictable during migration to TavilyClient.

Testing

  • source .venv/bin/activate && pytest -q

Note

Low Risk
Low risk: changes are limited to a deprecated wrapper constructor and add tests; core request/response logic is untouched.

Overview
Restores backward-compatible initialization for the deprecated Client wrapper by accepting Client(api_key=...), Client({"api_key": ...}), and Client("...") and forwarding them as proper keyword args to TavilyClient.

Adds regression tests asserting the DeprecationWarning is emitted and the API key is set correctly for keyword-arg and legacy-dict construction.

Written by Cursor Bugbot for commit da30ade. This will update automatically on new commits. Configure here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant