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 #1663

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

Solution #1663

wants to merge 2 commits into from

Conversation

kmalashchuk
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 submission! Your code is on the right track and meets many of the task requirements. However, there are a couple of critical issues that need to be addressed before we can approve the pull request:

  1. Spouse Handling: The current implementation assumes that all spouse names are unique and present in the data. This can lead to unexpected behavior if a spouse's name is not found, resulting in a None value being assigned. Please add error handling or validation to ensure that the spouse exists in the data.

  2. Class-Level Dictionary: Using a class-level dictionary people to store instances can cause issues if multiple instances of Person are created in different contexts or threads. Consider using an instance-level attribute or a different design pattern to manage Person instances to avoid potential conflicts.

Once these issues are addressed, your code will be in great shape! Keep up the good work, and feel free to reach out if you have any questions or need further guidance. 😊

✨ 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.

app/main.py Outdated
@@ -1,8 +1,29 @@
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-level dictionary people to store instances of Person can lead to issues if multiple instances of Person are created in different contexts or threads. Consider using an instance-level attribute or a different design pattern to manage Person instances.

app/main.py Outdated
Comment on lines 25 to 27
spouse_name = person.get("wife") or person.get("husband")
if spouse_name:
Person.people[name].spouse = Person.people.get(spouse_name)

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 spouse's name is unique and present in the people_data. If a spouse's name is not found in Person.people, this will result in a None value being assigned to spouse, which might not be the intended behavior. Consider adding error handling or validation to ensure that the spouse exists in the data.

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.

Great effort on your submission! 🎉 Your code is mostly well-structured and aligns with the task requirements. However, there are a few critical issues that need attention:

  1. Spouse Handling: You've implemented error handling for missing spouse names by raising a ValueError, which is a good approach. Ensure this behavior aligns with the task requirements.

  2. Class-Level Dictionary: The task requires a class attribute people in the Person class to store instances by their name. Currently, a local dictionary person_dict is used within the create_person_list function. Please update this to meet the task requirements.

  3. Indentation Error: The return statement in the create_person_list function is incorrectly indented. It should be placed outside the loop to ensure all entries in people_data are processed.

These issues are important for the functionality of your code, and addressing them will enhance your solution. The decision to approve is made to help you move forward with your learning. Please review the comments and improve your code accordingly. 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! ✨

Comment on lines +31 to +32

return list(person_dict.values())

Choose a reason for hiding this comment

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

The return statement is incorrectly indented. It should be outside the for loop to ensure that all entries in people_data are processed before returning the list of Person objects.

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