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

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

Solution #1640

wants to merge 2 commits into from

Conversation

Hlibynka
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. Undefined Attributes: The Person class currently lacks the wife and husband attributes, which are being set in your code. This will lead to an AttributeError if these attributes are accessed later. Please define these attributes in the Person class, possibly initializing them to None, to prevent runtime errors.

  2. Non-Unique Names in people Dictionary: The use of a class-level people dictionary to store Person instances by name can cause issues if names are not unique, as it will overwrite existing entries with the same name. Consider using a different key or structure to ensure that each Person instance is stored uniquely.

Once these issues are resolved, 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 assistance. 🌟

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


people = {}

Choose a reason for hiding this comment

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

The people dictionary is used to store Person instances by name. This could lead to issues if names are not unique, as it will overwrite existing entries with the same name. Consider using a different key or structure to ensure uniqueness.

app/main.py Outdated
Comment on lines 24 to 27
if "wife" in person_data and person_data["wife"]:
current_person.wife = Person.people[person_data["wife"]]
if "husband" in person_data and person_data["husband"]:
current_person.husband = Person.people[person_data["husband"]]

Choose a reason for hiding this comment

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

The code attempts to set wife and husband attributes on Person instances, but these attributes are not defined in the Person class. This will result in an AttributeError if accessed later. Consider defining these attributes in the Person class, perhaps initializing them to None.

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 job on addressing the previous issues in your code! 🎉 The Person class now correctly includes the wife and husband attributes, initialized to None, which prevents any AttributeError when these attributes are accessed. However, be cautious with the use of delattr to remove attributes, as it can lead to errors if those attributes are accessed later. Instead, consider setting them to None if they are not provided.

Additionally, while the use of a class-level dictionary people to store Person instances by name is suitable given the task's constraints of unique names, always be mindful of potential issues with non-unique identifiers in different contexts.

The code meets the task requirements, and the decision to approve is made to help you move forward with your learning. Please review the comments to improve your code further. 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! ✨

if "wife" in person_data and person_data["wife"]:
current_person.wife = Person.people[person_data["wife"]]
else:
delattr(current_person, "wife")

Choose a reason for hiding this comment

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

Using delattr to remove the wife attribute can lead to AttributeError if the attribute is accessed later. Consider setting current_person.wife = None instead.

if "husband" in person_data and person_data["husband"]:
current_person.husband = Person.people[person_data["husband"]]
else:
delattr(current_person, "husband")

Choose a reason for hiding this comment

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

Using delattr to remove the husband attribute can lead to AttributeError if the attribute is accessed later. Consider setting current_person.husband = None instead.

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