Sync GithubIntegration __init__ arguments with github.Github (#2556)

Github and GithubIntegration now both support the same (full) set of Requester arguments.
Creating a Github instance for a Github App Installation coming from GithubIntegration uses the same
Requester arguments (except for auth).
This commit is contained in:
Enrico Minack
2023-06-21 09:04:19 +02:00
committed by GitHub
parent f4e9dcb341
commit ea45237d3b
16 changed files with 333 additions and 27 deletions
+24 -12
View File
@@ -344,6 +344,7 @@ class Requester:
__hostname: str
__authorizationHeader: Optional[str]
# keep arguments in-sync with github.MainClass and GithubIntegration
def __init__(
self,
auth: Optional["Auth"],
@@ -351,7 +352,7 @@ class Requester:
timeout: int,
user_agent: str,
per_page: int,
verify: bool,
verify: Union[bool, str],
retry: Optional[Union[int, Retry]],
pool_size: Optional[int],
):
@@ -394,6 +395,24 @@ class Requester:
if isinstance(self.__auth, WithRequester):
self.__auth.withRequester(self)
@property
def kwargs(self):
"""
Returns arguments required to recreate this Requester with Requester.__init__, as well as
with MainClass.__init__ and GithubIntegration.__init__.
:return:
"""
return dict(
auth=self.__auth,
base_url=self.__base_url,
timeout=self.__timeout,
user_agent=self.__userAgent,
per_page=self.per_page,
verify=self.__verify,
retry=self.__retry,
pool_size=self.__pool_size,
)
@property
def base_url(self) -> str:
return self.__base_url
@@ -406,18 +425,11 @@ class Requester:
"""
Create a new requester instance with identical configuration but the given authentication method.
:param auth: authentication method
:return: new Reqester implementation
:return: new Requester implementation
"""
return Requester(
auth=auth,
base_url=self.__base_url,
timeout=self.__timeout,
user_agent=self.__userAgent,
per_page=self.per_page,
verify=self.__verify,
retry=self.__retry,
pool_size=self.__pool_size,
)
kwargs = self.kwargs
kwargs.update(auth=auth)
return Requester(**kwargs)
def requestJsonAndCheck(
self,