Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gil9red opened this issue Jan 10, 2021 · 6 comments · Fixed by #1020
Closed

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

gil9red opened this issue Jan 10, 2021 · 6 comments · Fixed by #1020
Assignees

Comments

@gil9red
Copy link

gil9red commented Jan 10, 2021

Error:

github3.exceptions.IncompleteResponse: None The library was expecting more data in the response (KeyError('additions')). Either GitHub modified it's response body, or your token is not properly scoped to retrieve this information.

Stack trace:

C:\Users\ipetrash\PycharmProjects\lenta_of_played_games\env\python3.7\python.exe C:/Users/ipetrash/PycharmProjects/lenta_of_played_games/main.py
[2021-01-10 11:36:07,547] main.py[LINE:15] INFO     Started!
Traceback (most recent call last):
  File "C:\Users\ipetrash\PycharmProjects\lenta_of_played_games\env\python3.7\lib\site-packages\github3\models.py", line 48, in __init__
    self._update_attributes(json)
  File "C:\Users\ipetrash\PycharmProjects\lenta_of_played_games\env\python3.7\lib\site-packages\github3\gists\history.py", line 61, in _update_attributes
    self.additions = self.change_status["additions"]
KeyError: 'additions'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/ipetrash/PycharmProjects/lenta_of_played_games/main.py", line 17, in <module>
    changed_1 = fill_gist_history.main()
  File "C:\Users\ipetrash\PycharmProjects\lenta_of_played_games\etc\fill_gist_history.py", line 24, in main
    gist = gh.gist('2f80a34fb601cd685353')
  File "C:\Users\ipetrash\PycharmProjects\lenta_of_played_games\env\python3.7\lib\site-packages\github3\github.py", line 951, in gist
    return self._instance_or_null(gists.Gist, json)
  File "C:\Users\ipetrash\PycharmProjects\lenta_of_played_games\env\python3.7\lib\site-packages\github3\models.py", line 146, in _instance_or_null
    return instance_class(json, self)
  File "C:\Users\ipetrash\PycharmProjects\lenta_of_played_games\env\python3.7\lib\site-packages\github3\models.py", line 48, in __init__
    self._update_attributes(json)
  File "C:\Users\ipetrash\PycharmProjects\lenta_of_played_games\env\python3.7\lib\site-packages\github3\gists\gist.py", line 333, in _update_attributes
    self.history = [history.GistHistory(h, self) for h in gist["history"]]
  File "C:\Users\ipetrash\PycharmProjects\lenta_of_played_games\env\python3.7\lib\site-packages\github3\gists\gist.py", line 333, in <listcomp>
    self.history = [history.GistHistory(h, self) for h in gist["history"]]
  File "C:\Users\ipetrash\PycharmProjects\lenta_of_played_games\env\python3.7\lib\site-packages\github3\models.py", line 50, in __init__
    raise exceptions.IncompleteResponse(json, kerr)
github3.exceptions.IncompleteResponse: None The library was expecting more data in the response (KeyError('additions')). Either GitHub modified it's response body, or your token is not properly scoped to retrieve this information.

GistHistory._update_attributes github3\gists\history.py line 61:

    self.additions = self.change_status["additions"]
    self.deletions = self.change_status["deletions"]
    self.total = self.change_status["total"]

After replacement, there was no problem, example:

    self.additions = self.change_status.get("additions")
    self.deletions = self.change_status.get("deletions")
    self.total = self.change_status.get("total")
@staticdev
Copy link
Collaborator

Thanks @gil9red, that was incorporated in #1020.

@staticdev
Copy link
Collaborator

@gil9red does it work if you only put get() on additions and deletions?

@gil9red
Copy link
Author

gil9red commented Jan 10, 2021

@staticdev, yes

@staticdev
Copy link
Collaborator

staticdev commented Jan 11, 2021

@gil9red is it also possible that you send us the json response you are getting so we map it correctly in the response structure of github3py? Just put a print(self.change_status) before self.additions = self.change_status.get("additions")

@gil9red
Copy link
Author

gil9red commented Jan 11, 2021

@staticdev, done

result:

{'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}
{}

@gil9red
Copy link
Author

gil9red commented Jan 12, 2021

Thanks! :)

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 a pull request may close this issue.

3 participants
@staticdev @gil9red and others