-
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
Solution #1663
base: master
Are you sure you want to change the base?
Solution #1663
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 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:
-
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. -
Class-Level Dictionary: Using a class-level dictionary
people
to store instances can cause issues if multiple instances ofPerson
are created in different contexts or threads. Consider using an instance-level attribute or a different design pattern to managePerson
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 = {} |
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.
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
spouse_name = person.get("wife") or person.get("husband") | ||
if spouse_name: | ||
Person.people[name].spouse = Person.people.get(spouse_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.
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.
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.
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:
-
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. -
Class-Level Dictionary: The task requires a class attribute
people
in thePerson
class to store instances by theirname
. Currently, a local dictionaryperson_dict
is used within thecreate_person_list
function. Please update this to meet the task requirements. -
Indentation Error: The
return
statement in thecreate_person_list
function is incorrectly indented. It should be placed outside the loop to ensure all entries inpeople_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! ✨
|
||
return list(person_dict.values()) |
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 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.
No description provided.