binance / binance/binance-connector-python
Type hint mismatch for list API responses
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 697
- PR merge metrics
- No merged PRs in 30d
Description
Hi! I’m currently using the `binance-sdk-derivatives-trading-usds-futures` SDK while migrating from the deprecated version.
I noticed that the return type of the USD Futures API is always annotated as `ApiResponse[T]`, but in cases where the response is a top-level list, the actual return type is `ApiResponse[list[T]]`.
Is this intentional?
```python
def send_request(...):
...
if (is_list and not is_flat_list) or not response_model:
data_function = lambda: parsed
elif is_oneof or is_list:
data_function = lambda: response_model.from_dict(parsed)
else:
data_function = lambda: response_model.model_validate(parsed)
```
```python
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[list[Self]]:
"""Create an instance of Ticker24hrResponse2 from a dict"""
return [cls.model_validate(item) for item in obj]
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.