From 0f2b844a4b788cf9efada9d121f38f129dbd7e56 Mon Sep 17 00:00:00 2001 From: staticdev Date: Sun, 10 Jan 2021 12:53:04 +0100 Subject: [PATCH 1/2] Fix gist.history keyerrors --- docs/source/release-notes/2.0.0.rst | 8 ++++++-- src/github3/gists/history.py | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/source/release-notes/2.0.0.rst b/docs/source/release-notes/2.0.0.rst index c0962ab20..3db632661 100644 --- a/docs/source/release-notes/2.0.0.rst +++ b/docs/source/release-notes/2.0.0.rst @@ -1,4 +1,4 @@ -2.0.0: 2020-01-06 +2.0.0: 2020-01-10 ----------------- Features Added @@ -10,6 +10,11 @@ Features Added - Remove compatibility imports for Python 2. - Remove dev-dependency for mock. +Bugs Fixed +`````````` + +* Key errors on Gist.history. + Removals ```````` @@ -56,4 +61,3 @@ Removals - ``Organization#add_member`` add ``username`` to ``team``. - ``Organization#events`` use ``Organization#public_events`` - ``Issue#assign`` use ``issues.issue.Issue.add_assignees`` - diff --git a/src/github3/gists/history.py b/src/github3/gists/history.py index c117be8ab..73c83c3fb 100644 --- a/src/github3/gists/history.py +++ b/src/github3/gists/history.py @@ -43,24 +43,24 @@ class GistHistory(models.GitHubCore): The number of deletions from the gist compared to the previous revision. - .. attribute:: totoal + .. attribute:: total The total number of changes to the gist compared to the previous revision. """ - def _update_attributes(self, history): + def _update_attributes(self, history) -> None: self.url = self._api = history["url"] self.version = history["version"] self.user = users.ShortUser(history["user"], self) - self.change_status = history["change_status"] - self.additions = self.change_status["additions"] - self.deletions = self.change_status["deletions"] - self.total = self.change_status["total"] - self.committed_at = self._strptime(history["committed_at"]) - - def _repr(self): - return "".format(self.version) + self.change_status = history.get("change_status") + self.additions = self.change_status.get("additions") + self.deletions = self.change_status.get("deletions") + self.total = self.change_status.get("total") + self.committed_at = self._strptime(history.get("committed_at")) + + def _repr(self) -> str: + return f"" def gist(self): """Retrieve the gist at this version. From 2bf638002b9558e65aba885adcdfc68217cee862 Mon Sep 17 00:00:00 2001 From: staticdev Date: Mon, 11 Jan 2021 13:10:33 +0100 Subject: [PATCH 2/2] Rollback changes to unnecessary fields --- src/github3/gists/history.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/github3/gists/history.py b/src/github3/gists/history.py index 73c83c3fb..bd7ddab1d 100644 --- a/src/github3/gists/history.py +++ b/src/github3/gists/history.py @@ -53,11 +53,11 @@ def _update_attributes(self, history) -> None: self.url = self._api = history["url"] self.version = history["version"] self.user = users.ShortUser(history["user"], self) - self.change_status = history.get("change_status") + self.change_status = history["change_status"] self.additions = self.change_status.get("additions") self.deletions = self.change_status.get("deletions") - self.total = self.change_status.get("total") - self.committed_at = self._strptime(history.get("committed_at")) + self.total = self.change_status["total"] + self.committed_at = self._strptime(history["committed_at"]) def _repr(self) -> str: return f""