Skip to content

Conversation

@staticdev
Copy link
Collaborator

@staticdev staticdev commented Jan 10, 2021

  • Uses get method for responses missing attributes.
  • Add some typing to return methods.
  • Fix a typo in docstring.
  • Add f-string for legibility.
  • Add release note.

Closes #1019

Comment on lines 56 to 61
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"))

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now makes it indistinguishable between GitHub returning null and the key being missing which semantically are two very different things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get() should be added then only to additions and deletions right?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So missing data makes me think there's a way that GitHub represents the data that is different than the object we have here. (Think about ShortUser versus User versus AuthenticatedUser. There's different representations of the same object with different data. The history object here seems to have another representation. It seems like this happens when retrieving a single gist by its id (in the original issue). Given that used to work, that means GitHub's changed something and we probably need a different representation here (sadly).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I'd love some kind of NotProvided singleton rather than this many objects but that proved confusing in the past

Copy link
Collaborator Author

@staticdev staticdev Jan 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sigmavirus24 I rolled back that changes for unnecessary fields. I am not really sure how to reproduce this other object representation and I don't have much knowledge of Github Gists. Could we use this PR as a hotfix to solve the user's problem and then we dig into this new structure in a new issue?

Copy link
Collaborator Author

@staticdev staticdev Jan 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sigmavirus24 also the user (on #1019) printed self.change_status before the error, the it is not quite another representation:

{'total': 2, 'additions': 1, 'deletions': 1}
{'total': 1, 'additions': 1, 'deletions': 0}
{'total': 4, 'additions': 2, 'deletions': 2}
{'total': 2, 'additions': 1, 'deletions': 1}
{'total': 1, 'additions': 1, 'deletions': 0}
{'total': 2, 'additions': 1, 'deletions': 1}
{'total': 3, 'additions': 2, 'deletions': 1}
{'total': 1, 'additions': 1, 'deletions': 0}
{'total': 4, 'additions': 2, 'deletions': 2}
{'total': 1, 'additions': 1, 'deletions': 0}
{}

@sigmavirus24 sigmavirus24 merged commit 6572d75 into master Jan 12, 2021
@sigmavirus24 sigmavirus24 deleted the fix-history-keyerrors branch January 12, 2021 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using method "get" instead operator [] in GistHistory._update_attributes

3 participants