-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Solution #2330
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
base: master
Are you sure you want to change the base?
Solution #2330
Conversation
mateacademy-ai-mentor
left a comment
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.
Review Summary
Good work on the overall structure and implementation of the Person class. The use of list comprehension is also well done.
However, this requires a change due to a critical functional issue. The Person.people class attribute is never cleared between calls to create_person_list. This causes data from previous calls to persist, leading to incorrect outputs if the function is run more than once. To fix this, you should clear the Person.people dictionary at the beginning of the function.
Additionally, while not a blocker, the code for linking spouses could be simplified by using dict.get() to fetch the person object, which is the recommended approach. [CHECKLIST ITEM #4]
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| def create_person_list(people: list) -> list: | ||
| # write your code here | ||
| pass | ||
| result = [ |
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 Person.people dictionary is a class attribute and is never cleared. If this function is called multiple times, it will accumulate Person instances from all previous calls, leading to incorrect results. Consider clearing this dictionary at the beginning of the function to ensure it works correctly for multiple independent calls.
app/main.py
Outdated
| if wife_name and wife_name in Person.people: | ||
| person.wife = Person.people[wife_name] |
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.
This violates checklist item #4: 'When accessing values in a dictionary, it is better to use the dict.get() method instead of explicitly checking for the presence of a key.' You can simplify this logic by using Person.people.get(wife_name) and then checking if the result is not None before assigning it.
app/main.py
Outdated
| if husband_name and husband_name in Person.people: | ||
| person.husband = Person.people[husband_name] |
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.
This violates checklist item #4: 'When accessing values in a dictionary, it is better to use the dict.get() method instead of explicitly checking for the presence of a key.' Similar to the wife attribute, you can simplify this by using Person.people.get(husband_name) to retrieve the husband instance.
mateacademy-ai-mentor
left a comment
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.
Sorry, the pull request review was unsuccessful for the following reasons:
Warning
No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]
If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.
mateacademy-ai-mentor
left a comment
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.
Review Summary
Great job fixing the critical bug from the last review by clearing the Person.people dictionary! The code is now functionally correct. However, one change is needed to fully align with the project's guidelines. The spouse-linking logic currently uses an in check on Person.people before accessing the value, which violates a checklist item [CHECKLIST ITEM #4]. You can simplify this by using Person.people.get(spouse_name) to retrieve the spouse's instance and check if the result is None in a single step. Please apply this pattern to finalize your solution.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
app/main.py
Outdated
| if wife_name and wife_name in Person.people: | ||
| person.wife = Person.people[wife_name] |
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.
This violates checklist item #4, which recommends using dict.get() instead of checking for key presence with in. You can simplify this by attempting to .get() the wife's instance from Person.people directly using wife_name as the key, and then checking if the result is not None. This same pattern should be applied to the husband-linking logic below.
mateacademy-ai-mentor
left a comment
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.
Review Summary
Excellent work! I am approving your solution as it's now perfect. You've successfully addressed the feedback from the previous review by using dict.get() for spouse linking, which aligns perfectly with the project's guidelines [CHECKLIST ITEM #4]. The code is now clean, efficient, and fully compliant with all requirements. Great job finishing this up!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.