datadog-api-client-python icon indicating copy to clipboard operation
datadog-api-client-python copied to clipboard

Type annotation of methods which are returning {api_endpoint}.call_with_http_info for asynchronous api is incorrect

Open zhukovgreen opened this issue 7 months ago • 3 comments

Describe the bug

For example in [1]:

    def create_spans_metric(
        self,
        body: SpansMetricCreateRequest,
    ) -> SpansMetricResponse:
        """Create a span-based metric.

        Create a metric based on your ingested spans in your organization.
        Returns the span-based metric object from the request body when the request is successful.

        :param body: The definition of the new span-based metric.
        :type body: SpansMetricCreateRequest
        :rtype: SpansMetricResponse
        """
        kwargs: Dict[str, Any] = {}
        kwargs["body"] = body

        return self._create_spans_metric_endpoint.call_with_http_info(**kwargs)

when the api client is async, the function returns coroutine. So the return type should be updated to

-    ) -> SpansMetricCreateRequest:
+    ) -> SpansMetricCreateRequest | Awaitable[SpansMetricCreateRequest]:

Type checkers are not happy about the current state

[1] https://github.com/DataDog/datadog-api-client-python/blob/master/src/datadog_api_client/v2/api/spans_metrics_api.py#L134-L150

zhukovgreen avatar Jun 13 '25 20:06 zhukovgreen

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

github-actions[bot] avatar Jul 17 '25 00:07 github-actions[bot]

Yes, it is reproducible

zhukovgreen avatar Aug 04 '25 14:08 zhukovgreen

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

github-actions[bot] avatar Sep 27 '25 00:09 github-actions[bot]