@@ -135,9 +135,7 @@ async def get_repository(
135135 Fetch repository metadata. Returns (repo_data, None) on success;
136136 (None, {"status": int, "message": str}) on failure for meaningful API responses.
137137 """
138- headers = await self ._get_auth_headers (
139- installation_id = installation_id , user_token = user_token
140- ) or {}
138+ headers = await self ._get_auth_headers (installation_id = installation_id , user_token = user_token ) or {}
141139 url = f"{ config .github .api_base_url } /repos/{ repo_full_name } "
142140 session = await self ._get_session ()
143141 async with session .get (url , headers = headers ) as response :
@@ -160,17 +158,18 @@ async def get_repository(
160158 if response .status == 401 :
161159 return (
162160 None ,
163- {"status" : 401 , "message" : gh_message or "Invalid or expired token. Check github_token or installation_id." },
161+ {
162+ "status" : 401 ,
163+ "message" : gh_message or "Invalid or expired token. Check github_token or installation_id." ,
164+ },
164165 )
165166 return None , {"status" : response .status , "message" : gh_message or f"GitHub API returned { response .status } ." }
166167
167168 async def list_directory_any_auth (
168169 self , repo_full_name : str , path : str , installation_id : int | None = None , user_token : str | None = None
169170 ) -> list [dict [str , Any ]]:
170171 """List directory contents using installation or user token (auth required)."""
171- headers = await self ._get_auth_headers (
172- installation_id = installation_id , user_token = user_token
173- ) or {}
172+ headers = await self ._get_auth_headers (installation_id = installation_id , user_token = user_token ) or {}
174173 url = f"{ config .github .api_base_url } /repos/{ repo_full_name } /contents/{ path } "
175174 session = await self ._get_session ()
176175 async with session .get (url , headers = headers ) as response :
@@ -183,29 +182,36 @@ async def list_directory_any_auth(
183182 response .raise_for_status ()
184183 return []
185184
186-
187185 async def get_repository_tree (
188- self ,
189- repo_full_name : str ,
190- ref : str | None = None ,
191- installation_id : int | None = None ,
192- user_token : str | None = None ,
193- recursive : bool = True ,
186+ self ,
187+ repo_full_name : str ,
188+ ref : str | None = None ,
189+ installation_id : int | None = None ,
190+ user_token : str | None = None ,
191+ recursive : bool = True ,
194192 ) -> list [dict [str , Any ]]:
195193 """Get the tree of a repository. Requires authentication (github_token or installation_id)."""
196194 start = time .monotonic ()
197- headers = await self ._get_auth_headers (
198- installation_id = installation_id ,
199- user_token = user_token ,
200- ) or {}
195+ headers = (
196+ await self ._get_auth_headers (
197+ installation_id = installation_id ,
198+ user_token = user_token ,
199+ )
200+ or {}
201+ )
201202 ref = ref or "main"
202203 tree_sha = await self ._resolve_tree_sha (repo_full_name , ref , headers )
203204 if not tree_sha :
204205 latency_ms = int ((time .monotonic () - start ) * 1000 )
205206 logger .info (
206207 "get_repository_tree" ,
207208 operation = "get_repository_tree" ,
208- subject_ids = {"repo" : repo_full_name , "installation_id" : installation_id , "user_token_present" : bool (user_token ), "ref" : ref },
209+ subject_ids = {
210+ "repo" : repo_full_name ,
211+ "installation_id" : installation_id ,
212+ "user_token_present" : bool (user_token ),
213+ "ref" : ref ,
214+ },
209215 decision = "ref_resolution_failed" ,
210216 latency_ms = latency_ms ,
211217 )
@@ -228,7 +234,6 @@ async def get_repository_tree(
228234 data = await response .json ()
229235 return cast ("list[dict[str, Any]]" , data .get ("tree" , []))
230236
231-
232237 async def _resolve_tree_sha (self , repo_full_name : str , ref : str , headers : dict [str , str ]) -> str | None :
233238 """Resolve the tree SHA for the given ref (branch, tag, or commit SHA) via the commits API."""
234239 session = await self ._get_session ()
@@ -254,11 +259,14 @@ async def get_file_content(
254259 Fetches the content of a file from a repository. Requires authentication (github_token or installation_id).
255260 When ref is provided (branch name, tag, or commit SHA), returns content at that ref; otherwise uses default branch.
256261 """
257- headers = await self ._get_auth_headers (
258- installation_id = installation_id ,
259- user_token = user_token ,
260- accept = "application/vnd.github.raw" ,
261- ) or {}
262+ headers = (
263+ await self ._get_auth_headers (
264+ installation_id = installation_id ,
265+ user_token = user_token ,
266+ accept = "application/vnd.github.raw" ,
267+ )
268+ or {}
269+ )
262270 url = f"{ config .github .api_base_url } /repos/{ repo_full_name } /contents/{ file_path } "
263271 params = {"ref" : ref } if ref else None
264272
@@ -1350,9 +1358,7 @@ async def execute_graphql(
13501358 payload = {"query" : query , "variables" : variables }
13511359
13521360 # Get appropriate headers (auth required: user_token or installation_id)
1353- headers = await self ._get_auth_headers (
1354- user_token = user_token , installation_id = installation_id
1355- )
1361+ headers = await self ._get_auth_headers (user_token = user_token , installation_id = installation_id )
13561362 if not headers :
13571363 # Fallback or error? GraphQL usually demands auth.
13581364 # If we have no headers, we likely can't query GraphQL successfully for many fields.
0 commit comments