Skip to content

Commit 048a1a3

Browse files
committed
Make GitTag.verification return GitCommitVerification (#3226)
Turns the return value of `GitTag.verification` from `dict` into a proper class. Completes #3028.
1 parent 9329744 commit 048a1a3

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

doc/changes.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ should be replaced with
2929
repo.get_views_traffic().views.timestamp
3030
repo.get_clones_traffic().clones.timestamp
3131
32+
* Add ``GitCommitVerification`` class (`#3028 <https://github.com/PyGithub/PyGithub/pull/3028>`_) (`822e6d71 <https://github.com/PyGithub/PyGithub/commit/822e6d71>`_):
33+
34+
Changes the return value of ``GitTag.verification`` and ``GitCommit.verification`` from ``dict`` to ``GitCommitVerification``.
35+
36+
Code like
37+
38+
.. code-block:: python
39+
40+
tag.verification["reason"]
41+
commit.verification["reason"]
42+
43+
should be replaced with
44+
45+
.. code-block:: python
46+
47+
tag.verification.reason
48+
commit.verification.reason
49+
3250
* Property ``AppAuth.private_key`` has been removed (`#3065 <https://github.com/PyGithub/PyGithub/pull/3065>`_) (`36697b22 <https://github.com/PyGithub/PyGithub/commit/36697b22>`_)
3351

3452
* Fix typos (`#3086 <https://github.com/PyGithub/PyGithub/pull/3086>`_) (`a50ae51b <https://github.com/PyGithub/PyGithub/commit/a50ae51b>`_):

github/GitTag.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@
4343
from typing import TYPE_CHECKING, Any
4444

4545
import github.GitAuthor
46+
import github.GitCommitVerification
4647
import github.GithubObject
4748
import github.GitObject
4849
import github.GitTreeElement
4950
from github.GithubObject import Attribute, CompletableGithubObject, NotSet
5051

5152
if TYPE_CHECKING:
5253
from github.GitAuthor import GitAuthor
54+
from github.GitCommitVerification import GitCommitVerification
5355
from github.GitObject import GitObject
5456

5557

@@ -73,7 +75,7 @@ def _initAttributes(self) -> None:
7375
self._tag: Attribute[str] = NotSet
7476
self._tagger: Attribute[GitAuthor] = NotSet
7577
self._url: Attribute[str] = NotSet
76-
self._verification: Attribute[dict[str, Any]] = NotSet
78+
self._verification: Attribute[GitCommitVerification] = NotSet
7779

7880
def __repr__(self) -> str:
7981
return self.get__repr__({"sha": self._sha.value, "tag": self._tag.value})
@@ -114,7 +116,7 @@ def url(self) -> str:
114116
return self._url.value
115117

116118
@property
117-
def verification(self) -> dict[str, Any]:
119+
def verification(self) -> GitCommitVerification:
118120
self._completeIfNotSet(self._verification)
119121
return self._verification.value
120122

@@ -134,4 +136,6 @@ def _useAttributes(self, attributes: dict[str, Any]) -> None:
134136
if "url" in attributes: # pragma no branch
135137
self._url = self._makeStringAttribute(attributes["url"])
136138
if "verification" in attributes: # pragma no branch
137-
self._verification = self._makeDictAttribute(attributes["verification"])
139+
self._verification = self._makeClassAttribute(
140+
github.GitCommitVerification.GitCommitVerification, attributes["verification"]
141+
)

tests/GitTag.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,4 @@ def testAttributes(self):
6565
"https://api.github.com/repos/PyGithub/PyGithub/git/tags/f5f37322407b02a80de4526ad88d5f188977bc3c",
6666
)
6767
self.assertEqual(repr(self.tag), 'GitTag(tag="v0.6", sha="f5f37322407b02a80de4526ad88d5f188977bc3c")')
68-
self.assertEqual(
69-
self.tag.verification,
70-
{"verified": False, "reason": "unsigned", "signature": None, "payload": None, "verified_at": None},
71-
)
68+
self.assertEqual(self.tag.verification.reason, "unsigned")

0 commit comments

Comments
 (0)