4040import github .Commit
4141import github .File
4242from github .GithubObject import Attribute , CompletableGithubObject , NotSet
43+ from github .PaginatedList import PaginatedList
4344
4445
4546class Comparison (CompletableGithubObject ):
@@ -51,7 +52,6 @@ def _initAttributes(self) -> None:
5152 self ._ahead_by : Attribute [int ] = NotSet
5253 self ._base_commit : Attribute [github .Commit .Commit ] = NotSet
5354 self ._behind_by : Attribute [int ] = NotSet
54- self ._commits : Attribute [list [github .Commit .Commit ]] = NotSet
5555 self ._diff_url : Attribute [str ] = NotSet
5656 self ._files : Attribute [list [github .File .File ]] = NotSet
5757 self ._html_url : Attribute [str ] = NotSet
@@ -80,10 +80,21 @@ def behind_by(self) -> int:
8080 self ._completeIfNotSet (self ._behind_by )
8181 return self ._behind_by .value
8282
83+ # This should be a method, but this used to be a property and cannot be changed without breaking user code
84+ # TODO: remove @property on version 3
8385 @property
84- def commits (self ) -> list [github .Commit .Commit ]:
85- self ._completeIfNotSet (self ._commits )
86- return self ._commits .value
86+ def commits (self ) -> PaginatedList [github .Commit .Commit ]:
87+ return PaginatedList (
88+ github .Commit .Commit ,
89+ self ._requester ,
90+ self .url ,
91+ {},
92+ None ,
93+ "commits" ,
94+ "total_commits" ,
95+ self .raw_data ,
96+ self .raw_headers ,
97+ )
8798
8899 @property
89100 def diff_url (self ) -> str :
@@ -137,8 +148,6 @@ def _useAttributes(self, attributes: dict[str, Any]) -> None:
137148 self ._base_commit = self ._makeClassAttribute (github .Commit .Commit , attributes ["base_commit" ])
138149 if "behind_by" in attributes : # pragma no branch
139150 self ._behind_by = self ._makeIntAttribute (attributes ["behind_by" ])
140- if "commits" in attributes : # pragma no branch
141- self ._commits = self ._makeListOfClassesAttribute (github .Commit .Commit , attributes ["commits" ])
142151 if "diff_url" in attributes : # pragma no branch
143152 self ._diff_url = self ._makeStringAttribute (attributes ["diff_url" ])
144153 if "files" in attributes : # pragma no branch
0 commit comments