-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
add files #1649
base: master
Are you sure you want to change the base?
add files #1649
Conversation
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.
Thank you for your hard work on this pull request! 😊 While your code meets most of the task requirements, there are a few critical issues that need to be addressed before we can approve it:
-
Error Handling for Non-existent References: When setting the 'wife' and 'husband' attributes, ensure that the referenced person exists in
Person.people
. This will prevent potentialKeyError
exceptions if the name is not found. Adding error handling for these cases is crucial to ensure the robustness of your code. -
Unique Names in
Person.people
: Thepeople
dictionary is used to store references toPerson
objects by their names. It's important to ensure that these names are unique to avoid overwriting existing entries, which could lead to incorrect relationships betweenPerson
objects.
Please address these issues to improve the functionality and reliability of your code. Once these changes are made, we can proceed with approving your pull request. Keep up the great work, and don't hesitate to reach out if you need any help! 🚀
✨ 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,25 @@ | |||
class Person: | |||
# write your code here | |||
pass | |||
people = {} |
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 people
dictionary is used to store references to Person
objects by their names. Ensure that names are unique to avoid overwriting existing entries.
persons.append(person) | ||
|
||
for person_data in people: | ||
person = Person.people[person_data["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.
Accessing Person.people
using person_data["name"]
assumes that the name exists in the dictionary. Consider adding error handling to manage cases where the name might not be found.
for person_data in people: | ||
person = Person.people[person_data["name"]] | ||
if "wife" in person_data and person_data["wife"]: | ||
setattr(person, "wife", Person.people[person_data["wife"]]) |
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.
When setting the 'wife' attribute, ensure that the referenced person exists in Person.people
. Otherwise, this could lead to a KeyError
if the name is not found.
if "wife" in person_data and person_data["wife"]: | ||
setattr(person, "wife", Person.people[person_data["wife"]]) | ||
if "husband" in person_data and person_data["husband"]: | ||
setattr(person, "husband", Person.people[person_data["husband"]]) |
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.
Similar to the 'wife' attribute, ensure that the 'husband' attribute is set only if the referenced person exists in Person.people
to avoid potential KeyError
.
No description provided.