-
Notifications
You must be signed in to change notification settings - Fork 34
fix/add_depth_to_legacy_async_client_orderbooks_queries #396
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "injective-py" | ||
version = "1.11.0" | ||
version = "1.11.1" | ||
description = "Injective Python SDK, with Exchange API Client" | ||
authors = ["Injective Labs <[email protected]>"] | ||
license = "Apache-2.0" | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,59 @@ | ||||||
import warnings | ||||||
from unittest.mock import MagicMock, patch | ||||||
|
||||||
import pytest | ||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
||||||
from pyinjective.core.network import Network | ||||||
|
||||||
|
||||||
class TestAsyncClientDeprecationWarnings: | ||||||
def test_async_client_deprecation_warning(self): | ||||||
"""Test that creating an AsyncClient instance raises a deprecation warning with correct details.""" | ||||||
with patch('pyinjective.async_client.IndexerClient'), \ | ||||||
patch('pyinjective.async_client.ChainGrpcBankApi'), \ | ||||||
patch('pyinjective.async_client.ChainGrpcAuthApi'), \ | ||||||
patch('pyinjective.async_client.ChainGrpcAuthZApi'), \ | ||||||
patch('pyinjective.async_client.ChainGrpcDistributionApi'), \ | ||||||
patch('pyinjective.async_client.ChainGrpcExchangeApi'), \ | ||||||
patch('pyinjective.async_client.ChainGrpcChainStream'), \ | ||||||
patch('pyinjective.async_client.asyncio.get_event_loop'): | ||||||
|
||||||
# Create a mock network to avoid actual network initialization | ||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
mock_network = MagicMock(spec=Network) | ||||||
mock_network.chain_cookie_assistant = MagicMock() | ||||||
mock_network.create_chain_grpc_channel = MagicMock() | ||||||
mock_network.create_chain_stream_grpc_channel = MagicMock() | ||||||
mock_network.official_tokens_list_url = "https://example.com/tokens.json" | ||||||
|
||||||
# Import here to avoid early import issues | ||||||
from pyinjective.async_client import AsyncClient | ||||||
|
||||||
# Capture warnings | ||||||
with warnings.catch_warnings(record=True) as warning_list: | ||||||
warnings.simplefilter("always") # Ensure all warnings are captured | ||||||
|
||||||
# Create AsyncClient instance - this should trigger the deprecation warning | ||||||
client = AsyncClient(network=mock_network) | ||||||
|
||||||
# Find the AsyncClient deprecation warning | ||||||
async_client_warnings = [ | ||||||
w for w in warning_list | ||||||
if issubclass(w.category, DeprecationWarning) and | ||||||
"AsyncClient from pyinjective.async_client is deprecated" in str(w.message) | ||||||
] | ||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
||||||
# Should have exactly one warning | ||||||
assert len(async_client_warnings) == 1 | ||||||
|
||||||
warning = async_client_warnings[0] | ||||||
# Check warning message contains migration advice | ||||||
assert "Please use AsyncClient from pyinjective.async_client_v2 instead" in str(warning.message) | ||||||
# Check warning category | ||||||
assert warning.category == DeprecationWarning | ||||||
|
assert warning.category == DeprecationWarning | |
assert warning.category is DeprecationWarning |
🧰 Tools
🪛 Ruff (0.12.2)
52-52: Use is
and is not
for type comparisons, or isinstance()
for isinstance checks
(E721)
🤖 Prompt for AI Agents
In tests/test_async_client_deprecation_warnings.py around line 52, the test
compares warning.category to DeprecationWarning using == which triggers E721;
change the comparison to use identity (warning.category is DeprecationWarning)
so the class object is compared by identity rather than equality, updating that
assertion accordingly.
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.
Missing import statement for the
warn
function. The code useswarn()
but there's no corresponding import statement visible. This will cause a NameError at runtime.Copilot uses AI. Check for mistakes.