mirror of
https://github.com/qdrant/qdrant-client.git
synced 2026-07-31 23:20:54 -05:00
* refactor: Refactored the way of warnings * remove unused imports * fix: Fix stacklevel in warnings * regenerated async * nit * Updated some warnings with show once * fix: Fix stack levels * Updated async * Update qdrant_client/qdrant_remote.py Co-authored-by: George <george.panchuk@qdrant.tech> * Update async client * Updated warnings * Updated warnings * Updated warnings * fix: fix warning level * fix: fix warning level in async * fix: revert append payload condition --------- Co-authored-by: George <george.panchuk@qdrant.tech>
25 lines
633 B
Python
25 lines
633 B
Python
import warnings
|
|
from typing import Optional
|
|
|
|
SEEN_MESSAGES = set()
|
|
|
|
|
|
def show_warning(message: str, category: type[Warning] = UserWarning, stacklevel: int = 2) -> None:
|
|
warnings.warn(message, category, stacklevel=stacklevel)
|
|
|
|
|
|
def show_warning_once(
|
|
message: str,
|
|
category: type[Warning] = UserWarning,
|
|
idx: Optional[str] = None,
|
|
stacklevel: int = 1,
|
|
) -> None:
|
|
"""
|
|
Show a warning of the specified category only once per program run.
|
|
"""
|
|
key = idx if idx is not None else message
|
|
|
|
if key not in SEEN_MESSAGES:
|
|
SEEN_MESSAGES.add(key)
|
|
show_warning(message, category, stacklevel)
|