-
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
Merged
aarmoa
merged 3 commits into
master
from
fix/add_depth_to_legacy_async_client_orderbooks_queries
Aug 20, 2025
Merged
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
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" | ||
|
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,57 @@ | ||
import warnings | ||
from unittest.mock import MagicMock, patch | ||
|
||
from pyinjective.core.network import Network | ||
|
||
|
||
class TestAsyncClientDeprecationWarnings: | ||
@patch("pyinjective.async_client.asyncio.get_event_loop") | ||
@patch("pyinjective.async_client.ChainGrpcChainStream") | ||
@patch("pyinjective.async_client.ChainGrpcExchangeApi") | ||
@patch("pyinjective.async_client.ChainGrpcDistributionApi") | ||
@patch("pyinjective.async_client.ChainGrpcAuthZApi") | ||
@patch("pyinjective.async_client.ChainGrpcAuthApi") | ||
@patch("pyinjective.async_client.ChainGrpcBankApi") | ||
@patch("pyinjective.async_client.IndexerClient") | ||
def test_async_client_deprecation_warning(self, *mocks): | ||
"""Test that creating an AsyncClient instance raises a deprecation warning with correct details.""" | ||
# Create a mock network to avoid actual network initialization | ||
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) | ||
] | ||
|
||
# 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 | ||
# Check stacklevel is working correctly (should point to this test file) | ||
assert "test_async_client_deprecation_warnings.py" in warning.filename | ||
|
||
# Verify the client was still created successfully | ||
assert client is not None | ||
assert hasattr(client, "network") | ||
assert client.network == mock_network |
Oops, something went wrong.
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.
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.