Skip to content
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

ref: copy signature of _request to plugin api client #74899

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion src/sentry_plugins/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
from sentry.shared_integrations.client import BaseApiClient, BaseInternalApiClient
from __future__ import annotations

from collections.abc import Mapping
from typing import Literal, overload

from requests import PreparedRequest, Response

from sentry.shared_integrations.client.base import BaseApiClient, BaseApiResponseX
from sentry.shared_integrations.client.internal import BaseInternalApiClient
from sentry.shared_integrations.exceptions import ApiUnauthorized
from sentry.users.services.usersocialauth.service import usersocialauth_service

Expand Down Expand Up @@ -36,6 +44,44 @@ def bind_auth(self, **kwargs):
kwargs["headers"]["Authorization"] = f"Bearer {token}"
return kwargs

@overload
def _request(
self,
method: str,
path: str,
headers: Mapping[str, str] | None = None,
data: Mapping[str, str] | None = None,
params: Mapping[str, str] | None = None,
auth: tuple[str, str] | str | None = None,
json: bool = True,
allow_text: bool | None = None,
allow_redirects: bool | None = None,
timeout: int | None = None,
ignore_webhook_errors: bool = False,
prepared_request: PreparedRequest | None = None,
raw_response: Literal[True] = ...,
) -> Response:
...

@overload
def _request(
self,
method: str,
path: str,
headers: Mapping[str, str] | None = None,
data: Mapping[str, str] | None = None,
params: Mapping[str, str] | None = None,
auth: str | None = None,
json: bool = True,
allow_text: bool | None = None,
allow_redirects: bool | None = None,
timeout: int | None = None,
ignore_webhook_errors: bool = False,
prepared_request: PreparedRequest | None = None,
raw_response: bool = ...,
) -> BaseApiResponseX:
...

def _request(self, method, path, **kwargs):
headers = kwargs.setdefault("headers", {})
headers.setdefault("Accept", "application/json, application/xml")
Expand Down
Loading