Skip to content

Solution#2941

Open
Vitalii85 wants to merge 2 commits into
mate-academy:masterfrom
Vitalii85:develop
Open

Solution#2941
Vitalii85 wants to merge 2 commits into
mate-academy:masterfrom
Vitalii85:develop

Conversation

@Vitalii85

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

I am requesting changes because there is a direct violation of the explicit dictionary-access guideline, which is treated as a required checklist item rather than a minor style preference. Functionally your Person class and create_person_list implementation look good: instances are created correctly, stored in Person.people, and spouse relationships are wired as intended when the corresponding dict value is not None. However, in app/main.py the conditions for assigning spouses use patterns like if person.get("wife") and person["wife"]: and similarly for husband; this matches the "Bad example" pattern described in [CHECKLIST ITEM #4], which explicitly says to prefer dict.get() and avoid combining it with direct key indexing. This matters because the checklist is part of the core requirements, and mixing get with [...] can reintroduce KeyError risks and contradicts the prescribed style.

To fix this, update the spouse-assignment conditions to rely only on person.get("wife") and person.get("husband") in both the condition and the subsequent access, for example if person.get("wife"): followed by current_person.wife = Person.people[person.get("wife")]. Make sure you remove any redundant person["wife"] or person["husband"] indexing in those if statements so that all dictionary reads follow the dict.get() guideline. Once you make that adjustment, your solution will fully meet both the functional requirements and the checklist expectations. Overall, your class design and logic are solid; this is a small but important correction to align with the required coding standard.


✨ 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread app/main.py Outdated
Comment thread app/main.py Outdated

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Your solution is approved because it correctly implements all the required functionality and follows the specified style constraints. The Person class has the proper name and age attributes, and each instance is registered in the class-level Person.people dictionary using the name as the key, which satisfies the core data structure requirement. The create_person_list function builds the list of Person instances via a list comprehension and then wires up spouse relationships by looking up the corresponding Person objects in Person.people, ensuring that wife and husband are stored as object references rather than strings. When wife or husband is not provided or is falsy, those attributes are simply not set, so accessing them raises an AttributeError as required by the task. You also met the checklist expectations: no nested if statements, appropriate use of dict.get(), descriptive naming, and clear, straightforward logic. Overall, the implementation is clean, correct, and aligned with the task, so there are no critical issues that need changes at this stage.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants