feat: raw情况添加dingo_id#394
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the to_raw_dict method in dingo/io/output/result_info.py to include the dingo_id field in the output dictionary. The review feedback points out that the current implementation modifies self.raw_data in-place, which could lead to unintended side effects; the reviewer suggests returning a new dictionary containing the updated fields instead.
Comment on lines
+43
to
45
| self.raw_data['dingo_id'] = self.dingo_id | ||
| self.raw_data['dingo_result'] = dingo_result | ||
| return self.raw_data |
Contributor
There was a problem hiding this comment.
to_raw_dict 方法直接修改了 self.raw_data 属性。这种原地修改(in-place mutation)会产生副作用,例如多次调用该方法会重复修改状态,或者导致 to_dict 方法返回的结果不一致(因为 to_dict 引用了同一个 raw_data 对象)。建议返回一个包含新字段的字典副本,以保持函数的纯粹性。
Suggested change
| self.raw_data['dingo_id'] = self.dingo_id | |
| self.raw_data['dingo_result'] = dingo_result | |
| return self.raw_data | |
| return { | |
| **self.raw_data, | |
| 'dingo_id': self.dingo_id, | |
| 'dingo_result': dingo_result, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.