File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33from typing_extensions import Self
44
55from ._types import (
6+ ContentNode ,
67 ContentTree ,
7- ContentTreeJSON ,
88 Contributor ,
99 ErrorMessage ,
1010 FullRepository ,
@@ -541,6 +541,7 @@ async def get_repo_content(
541541 mediareturntype = "application/vnd.github+json"
542542
543543 try :
544+ # print(f">> Fetching content from repos/{owner}/{repo}/contents/{path} with mediatype {mediatype}")
544545 res = await cls .req (
545546 "GET" ,
546547 f"repos/{ owner } /{ repo } /contents/{ path } " ,
@@ -560,7 +561,12 @@ async def get_repo_content(
560561 case "raw" | "html" :
561562 return (res .status_code , res .content )
562563 case _:
563- return (res .status_code , ContentTree (** res .json ()))
564+ data = res .json ()
565+ # If the API returned a file, it will not have an 'entries' key.
566+ if "entries" in data :
567+ return (res .status_code , ContentTree (** data ))
568+
569+ return (res .status_code , ContentNode (** data ))
564570 except Exception as e :
565571 return (
566572 500 ,
Original file line number Diff line number Diff line change 1- import string
2- from datetime import datetime
31from typing import (
4- Any ,
5- Dict ,
62 List ,
7- Literal ,
83 NotRequired ,
94 Optional ,
105 TypedDict ,
@@ -27,7 +22,7 @@ class ContentLink(BaseModel):
2722
2823class ContentNodeJSON (TypedDict ):
2924 type : str
30- size : str
25+ size : int
3126 name : str
3227 path : str
3328 sha : str
@@ -41,7 +36,7 @@ class ContentNodeJSON(TypedDict):
4136
4237class ContentNode (BaseModel ):
4338 type : str
44- size : str
39+ size : int
4540 name : str
4641 path : str
4742 sha : str
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44
55[project ]
66name = " asyncPyGithub"
7- version = " 0.1.0.1 "
7+ version = " 0.1.0.3 "
88description = " Async Python wrapper for the GitHub API"
99readme = " README.md"
1010license = " MIT"
You can’t perform that action at this time.
0 commit comments