-
Notifications
You must be signed in to change notification settings - Fork 668
Open
Description
From the recent SDK update, the return of data = response.data() of client.rest_api.query_order is a dictionary.
But when I tried to access the data like status = data["status"], it works at runtime, but it reports an error in my editor:
Cannot subscript object of type `QueryOrderResponse` with no `__getitem__` method
This is likely due to incorrect or incomplete type definitions in the SDK, causing the linter/diagnostics to report errors that don't align with actual runtime behavior.
My workaround in order to suppress the error is casting the data with data = cast(dict, response.data()). It's supposed to work without the casting.
My full example script
import logging
from binance_sdk_derivatives_trading_usds_futures.derivatives_trading_usds_futures import (
ConfigurationRestAPI,
DerivativesTradingUsdsFutures,
)
# Configure logging
logging.basicConfig(level=logging.INFO)
# Create configuration for the REST API
configuration_rest_api = ConfigurationRestAPI(
api_key="xxx",
api_secret="xxx",
base_path="https://demo-fapi.binance.com",
)
# Initialize DerivativesTradingUsdsFutures client
client = DerivativesTradingUsdsFutures(config_rest_api=configuration_rest_api)
def query_order():
try:
response = client.rest_api.query_order(
symbol="BTCUSDT",
order_id=12035280468,
)
data = response.data()
# Extract and print the specific values - treating data as dict based on print output
status = data["status"]
print(f"Status: {status}")
except Exception as e:
logging.error(f"query_order() error: {e}")
query_order()binance-common 3.5.0
binance-sdk-derivatives-trading-usds-futures 7.0.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels