Skip to content

Type hint mismatch for list API responses #444

@zionhann

Description

@zionhann

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?

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)
    @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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions