respecting ordered sequence while partial update is fixed#9902
respecting ordered sequence while partial update is fixed#9902Natgho wants to merge 19 commits intoencode:mainfrom
Conversation
|
I considered including the ticket ID in the Description section of the test section, but decided it would be excessive. If you want it included, just let me know. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
The issues have been resolved and the PR looks ready. Is there anything else that needs improvement? |
|
lets wait for final rounds of reviews |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Finally! |
|
@auvipy what do you think? |
|
@auvipy I would appreciate your feedback. |
rest_framework/fields.py
Outdated
| except (TypeError, KeyError, AttributeError): | ||
| # Fall back to treating the value as not provided. | ||
| val = [] |
There was a problem hiding this comment.
Can you explain why we need this try/except? This line is not covered by the test so I'm curious...
There was a problem hiding this comment.
The purpose of this is to ensure that the code flow continues so that the rendering process can be completed without interruption, even if the field cannot be converted in any way or if the getlist function throws an error. Since I don’t have an example of this, I don’t have a test for it either, but it’s not impossible—I’d rather be a bit overzealous than take a chance.
There was a problem hiding this comment.
Ok, let's break this down:
- The condition above checks
html.is_html_input(dictionary)which checks that the dictionary has agetlistmethod, so I don't see how theAttributeErrorcan happen - The
QueryDictdocs states that "It’s guaranteed to return a list unless the default value provided isn’t a list."
There was a problem hiding this comment.
I see. Yes, you're right, it's impossible to get an AttributeError here, so I removed that AttributeError.
There was a problem hiding this comment.
What about the other 2 exception types? We've not needed them so far, what changed that makes it needed?
|
Also... What's up with all these added comments on code which basically unchanged? They are quite distracting... Did you write them or was it the work of an LLM? |
I created the PR using AI, and I’m manually pushing AI for comment lines so I can track every action it takes in detail. If they seem intrusive or unnecessary, I can remove the comment lines. |
browniebroke
left a comment
There was a problem hiding this comment.
Also... What's up with all these added comments on code which basically unchanged? They are quite distracting... Did you write them or was it the work of an LLM?
I created the PR using AI, and I’m manually pushing AI for comment lines so I can track every action it takes in detail. If they seem intrusive or unnecessary, I can remove the comment lines.
Ok that makes sense while you building it but I find the ratio of comments to code quite distracting, there are a
| # Call getlist with a single argument to support duck-typed MultiDicts | ||
| # that do not accept a default parameter. |
There was a problem hiding this comment.
That kind of explain why it was changed from dictionary.getlist(self.field_name, []) and exception handling was added, however this sems out of scope of what we're trying to achieve here. Let's keep the call how it was unless you can come up with a concrete example justifying this
| # For partial updates, avoid calling parse_html_list unless indexed keys are present. | ||
| # This reduces unnecessary parsing overhead for omitted list fields. |
| # For partial updates, avoid calling parse_html_list unless indexed keys are present. | ||
| # This reduces unnecessary parsing overhead for omitted list fields. | ||
| if getattr(self.root, 'partial', False): | ||
| # Quick check: are there any keys matching field_name[*]? |
| # Parse indexed keys (e.g., field[0], field[1]) | ||
| # This handles form submissions with explicit indices |
There was a problem hiding this comment.
Redundant with parse_html_list docstring
refs #6202