3737TOKEN_REFRESH_THRESHOLD_TIMEDELTA = timedelta (
3838 seconds = ACCESS_TOKEN_REFRESH_THRESHOLD_SECONDS
3939)
40- assert hasattr (
41- Auth , " TOKEN_REFRESH_THRESHOLD_TIMEDELTA"
42- ), "Could not monkey patch TOKEN_REFRESH_THRESHOLD_TIMEDELTA, it may have changed upstream."
40+ assert hasattr (Auth , "TOKEN_REFRESH_THRESHOLD_TIMEDELTA" ), (
41+ "Could not monkey patch TOKEN_REFRESH_THRESHOLD_TIMEDELTA, it may have changed upstream. "
42+ )
4343Auth .TOKEN_REFRESH_THRESHOLD_TIMEDELTA = TOKEN_REFRESH_THRESHOLD_TIMEDELTA
4444
4545BOT_USER_LOGIN_SUFFIX = "[bot]"
@@ -65,9 +65,9 @@ def __init__(
6565 app_auth : Optional [Auth .AppInstallationAuth ] = None ,
6666 http_retries : Optional [int ] = None ,
6767 ) -> None :
68- assert bool (github_oauth_token ) ^ bool (
69- app_auth
70- ), "Only one of github_oauth_token or app_auth can be set"
68+ assert bool (github_oauth_token ) ^ bool (app_auth ), (
69+ "Only one of github_oauth_token or app_auth can be set"
70+ )
7171 self .repo_name : str = os .path .basename (repo_url )
7272 self .base_repo_url : str = repo_url
7373 self .auth_type = AuthType .UNKNOWN
@@ -89,12 +89,9 @@ def __init__(
8989 self .github_account_name = gh_user .login
9090 else :
9191 self .auth_type = AuthType .APP_AUTH
92+ # In PyGithub 2.x, AppInstallationAuth stores the AppAuth object in _app_auth
9293 # pyrefly: ignore # missing-attribute
93- app = GithubIntegration (
94- auth = Auth .AppAuth (
95- app_id = app_auth .app_id , private_key = app_auth .private_key
96- )
97- ).get_app ()
94+ app = GithubIntegration (auth = app_auth ._app_auth ).get_app ()
9895 self .github_account_name = app .name
9996 # Github appends '[bot]' suffix to the NamedUser
10097 # >>> pull.user
@@ -138,9 +135,9 @@ def __init__(
138135 self .user_or_org = org
139136 self .repo = self .git .get_organization (org ).get_repo (self .repo_name )
140137
141- assert (
142- self . auth_type != AuthType . UNKNOWN
143- ), "Auth type is still set to unknown... something is wrong."
138+ assert self . auth_type != AuthType . UNKNOWN , (
139+ "Auth type is still set to unknown... something is wrong."
140+ )
144141
145142 def __get_new_auth_token (self ) -> str :
146143 # refresh token if needed
0 commit comments