-
Notifications
You must be signed in to change notification settings - Fork 3
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
[#243] Fix expand query parameter #286
Conversation
03821ea
to
8e27f8e
Compare
8e27f8e
to
6137dd5
Compare
if child.many: | ||
results.setdefault(child.label, []).append(child_result) | ||
child_results = results.setdefault(child.label, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I wrong or is child_results
not used for anything? We populate the list but we don't return it or append it to results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setdefault
call for the results
dictionary ensures that the child.label
key exists with the value of a list. It also returns said list which will be used later on (if child_result
has a value set).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I get this right, you are mutating the results because child_results
has a reference to it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this a bit more readable? Because this does make it quite difficult to comprehend what is happening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't remove the setdefault
usage as I think it handles various things through a single method call (setting the value if it is not present, retrieving its content). I did add some type hints in case people are not familiar with the method. The nested if statements were also removed to make things more readable.
data = None | ||
id = str(uuid4()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why we need to fill id when there is no object? From what I can quickly see locally this isn't necessary.
Fixes #243
Changes
Shows given expand query parameter results even when these are empty or
null
.