-
Notifications
You must be signed in to change notification settings - Fork 290
feat(client): add __repr__ to the six client classes
#1346
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
Open
Aryan-Pardeshi
wants to merge
2
commits into
qdrant:dev
Choose a base branch
from
Aryan-Pardeshi:feat/client-repr-dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import pytest | ||
|
|
||
| from qdrant_client import AsyncQdrantClient, QdrantClient | ||
| from qdrant_client.async_qdrant_remote import AsyncQdrantRemote | ||
| from qdrant_client.local.async_qdrant_local import AsyncQdrantLocal | ||
| from qdrant_client.local.qdrant_local import QdrantLocal | ||
| from qdrant_client.qdrant_remote import QdrantRemote | ||
|
|
||
|
|
||
| def test_local_client_repr_shows_location(): | ||
| assert repr(QdrantClient(":memory:")) == "<QdrantClient mode=local location=':memory:'>" | ||
|
|
||
|
|
||
| def test_async_local_client_repr_shows_location(): | ||
| assert ( | ||
| repr(AsyncQdrantClient(":memory:")) == "<AsyncQdrantClient mode=local location=':memory:'>" | ||
| ) | ||
|
|
||
|
|
||
| def test_persistent_local_client_repr_shows_path(tmp_path): | ||
| path = str(tmp_path / "storage") | ||
| assert repr(QdrantClient(path=path)) == f"<QdrantClient mode=local location={path!r}>" | ||
|
|
||
|
|
||
| def test_remote_client_repr_shows_host_and_grpc_preference(): | ||
| client = QdrantClient("localhost", port=6333, prefer_grpc=True) | ||
| assert repr(client) == "<QdrantClient mode=remote host='localhost:6333' prefer_grpc=True>" | ||
|
|
||
|
|
||
| def test_async_remote_client_repr_shows_host_and_grpc_preference(): | ||
| client = AsyncQdrantClient("localhost", port=6333, prefer_grpc=True) | ||
| assert repr(client) == "<AsyncQdrantClient mode=remote host='localhost:6333' prefer_grpc=True>" | ||
|
|
||
|
|
||
| def test_remote_repr_shows_scheme(): | ||
| remote = QdrantRemote(url="https://api.qdrant.example:443") | ||
| assert ( | ||
| repr(remote) | ||
| == "<QdrantRemote scheme=https host='api.qdrant.example:443' prefer_grpc=False>" | ||
| ) | ||
|
|
||
|
|
||
| def test_async_remote_repr_shows_scheme(): | ||
| remote = AsyncQdrantRemote(url="https://api.qdrant.example:443") | ||
| assert ( | ||
| repr(remote) | ||
| == "<AsyncQdrantRemote scheme=https host='api.qdrant.example:443' prefer_grpc=False>" | ||
| ) | ||
|
|
||
|
|
||
| def test_local_repr(): | ||
| assert repr(QdrantLocal(":memory:")) == "<QdrantLocal location=':memory:'>" | ||
|
|
||
|
|
||
| def test_async_local_repr(): | ||
| assert repr(AsyncQdrantLocal(":memory:")) == "<AsyncQdrantLocal location=':memory:'>" | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "client", | ||
| [ | ||
| QdrantClient("localhost", port=6333, api_key="super-secret-key"), | ||
| QdrantClient(url="https://api.qdrant.example:443", api_key="super-secret-key"), | ||
| ], | ||
| ) | ||
| def test_api_key_never_appears_in_repr(client): | ||
| assert "super-secret-key" not in repr(client) | ||
| assert "super-secret-key" not in repr(client._client) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: qdrant/qdrant-client
Length of output: 12576
🏁 Script executed:
Repository: qdrant/qdrant-client
Length of output: 50376
🏁 Script executed:
Repository: qdrant/qdrant-client
Length of output: 286
🏁 Script executed:
Repository: qdrant/qdrant-client
Length of output: 3265
Disable compatibility checks for representation-only tests.
These six remote clients start background version-check requests with the default
check_compatibility=True. Passcheck_compatibility=Falseto prevent requests tolocalhostandapi.qdrant.example.🤖 Prompt for AI Agents
Source: MCP tools