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

GroupedSubmission 'submissions' key:value deleted #303

Closed
Thetwam opened this issue Sep 30, 2019 · 1 comment · Fixed by #340
Closed

GroupedSubmission 'submissions' key:value deleted #303

Thetwam opened this issue Sep 30, 2019 · 1 comment · Fixed by #340
Assignees
Labels

Comments

@Thetwam
Copy link
Member

Thetwam commented Sep 30, 2019

Describe the bug

In #280 we added the first instance of nesting a list of one type of object inside another. While this generally works well, there is a small side effect: The 'submissions' key:value pair is removed from the attributes dict. This is potentially misleading, since one of the uses of calling attributes is to see what data was originally used to create the object (via .to_json()).

'submissions' being removed may give the (incorrect) impression that submissions were never returned from Canvas.

To Reproduce

Steps to reproduce the behavior:

  1. Create a GroupedSubmission object with nested submissions
  2. Print the attributes of the created object (print(grouped_submission.attributes))
  3. Observe that there is no 'submissions' key:value pair

Expected behavior

'submissions' should be visible in the printed attributes, to assist in debugging.

Environment information

  • Python version (python --version)
    3.7+

  • CanvasAPI version (pip show canvasapi)
    0.14.0

Additional context

This is somewhat related to #56, as we'll need to be careful about deleting keys in the future.

@Thetwam Thetwam added the bug label Sep 30, 2019
@Thetwam Thetwam added this to the CanvasAPI v0.15.0 milestone Sep 30, 2019
@Thetwam
Copy link
Member Author

Thetwam commented Sep 30, 2019

try:
self.submissions = [
Submission(requester, submission)
for submission in attributes["submissions"]
]
del attributes["submissions"]
except KeyError:
self.submissions = list()
super(GroupedSubmission, self).__init__(requester, attributes)

The issue lies here. We're deleting the 'submissions' key before it's passed off to CanvasObject.__init__(). We could call super() first, then override self.submissions after, although that does mean a little bit of extra processing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant