Skip to content
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

Solution #1594

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Solution #1594

wants to merge 3 commits into from

Conversation

IvankaKuzin
Copy link

No description provided.

Copy link

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

Choose a reason for hiding this comment

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

Thank you for your hard work on this pull request! 😊 While your code meets most of the task requirements, there are a couple of critical issues that need to be addressed before we can approve it:

  1. Handling Non-Existent Spouses: The current implementation assumes that the 'wife' and 'husband' keys will always have valid corresponding entries in the people dictionary. This could lead to a KeyError if a specified spouse does not exist. Please add a check to ensure that the spouse exists in the people dictionary before assigning them.

  2. Unique Identification for People: Using a class variable people to store instances by name can cause problems if names are not unique. Consider using a unique identifier or implementing a strategy to handle potential name collisions to ensure the integrity of your data.

By addressing these issues, your code will be more robust and reliable. Keep up the great work, and I look forward to seeing your improvements! 🚀

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

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

@@ -1,8 +1,26 @@
class Person:
# write your code here
pass
people = {}

Choose a reason for hiding this comment

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

Using a class variable people to store instances by name can lead to issues if names are not unique. Consider using a unique identifier or handling potential name collisions.

app/main.py Outdated
Comment on lines 21 to 24
if "wife" in person_data and person_data.get("wife"):
person.wife = Person.people[person_data.get("wife")]
if "husband" in person_data and person_data.get("husband"):
person.husband = Person.people[person_data.get("husband")]

Choose a reason for hiding this comment

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

The code assumes that the 'wife' and 'husband' keys, if present, will always have valid corresponding entries in the people dictionary. This could lead to a KeyError if the specified spouse does not exist. Consider adding a check to ensure the spouse exists in the people dictionary before assigning.

Copy link

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

Choose a reason for hiding this comment

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

Thank you for your submission! Your implementation of the Person class and the create_person_list function is a great start. However, there are a few critical issues that need attention to ensure the robustness and reliability of your code:

  1. Handling Non-Existent Spouses: Your code assumes that the 'wife' and 'husband' keys will always have valid corresponding entries in the people dictionary. This could lead to a KeyError if a specified spouse does not exist. To prevent this, consider using the dict.get() method to safely access the spouse from the people dictionary.

  2. Unique Identification for People: While the task description specifies that all names are different, using names as keys in the people dictionary can still be risky if this assumption doesn't hold in all scenarios. Consider implementing a strategy to handle potential name collisions or using unique identifiers.

Despite these issues, I am approving your pull request to help you move forward with your learning. Please review the comments and address these issues in future iterations to improve your code's robustness and functionality. Keep up the good work, and continue learning from these experiences! 🚀

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

app/main.py Outdated
person_object = Person.people[person["name"]]
if "wife" in person:
if person["wife"]:
wife = Person.people[person["wife"]]

Choose a reason for hiding this comment

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

Issue: The code assumes that the 'wife' exists in the Person.people dictionary. This can lead to a KeyError if the specified wife does not exist.

Suggestion: Add a check to ensure that the wife exists in the Person.people dictionary before assigning them.

app/main.py Outdated
person_object.wife = wife
elif "husband" in person:
if person["husband"]:
husband = Person.people[person["husband"]]

Choose a reason for hiding this comment

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

Issue: The code assumes that the 'husband' exists in the Person.people dictionary. This can lead to a KeyError if the specified husband does not exist.

Suggestion: Add a check to ensure that the husband exists in the Person.people dictionary before assigning them.

@@ -1,8 +1,26 @@
class Person:
# write your code here
pass
people = {}

Choose a reason for hiding this comment

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

Issue: Using names as keys in the people dictionary can cause issues if names are not unique.

Suggestion: Consider using a unique identifier for each person or implement a strategy to handle potential name collisions.

app/main.py Outdated
Comment on lines 16 to 20
for person in people:
person_object = Person.people[person["name"]]
if "wife" in person:
if person["wife"]:
wife = Person.people[person["wife"]]

Choose a reason for hiding this comment

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

Please simplify this condition by using only method .get(). This level of nesting is not good solution.

@IvankaKuzin IvankaKuzin requested a review from petrykivd December 4, 2024 11:36
Copy link

@petrykivd petrykivd left a comment

Choose a reason for hiding this comment

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

Great! 😎

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.

4 participants