-
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 #1629
base: master
Are you sure you want to change the base?
Solution #1629
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:
-
Key Handling: The code assumes that keys like
wife
andhusband
will always correspond to valid names in thePerson.people
dictionary. This can lead toKeyError
exceptions if the assumption is incorrect. Please ensure that the input data is validated or handle these exceptions appropriately. -
Class Variable Usage: The
people
dictionary is currently defined as a class variable, which means it is shared across all instances of thePerson
class. If this shared behavior is not intended, consider using an instance variable instead to avoid potential issues. -
Variable Naming: The variable name
peoples
is misleading as it suggests a plural form. Renaming it to something likeperson_data
would better reflect its purpose and improve code readability.
Addressing these issues will enhance the robustness and clarity of your code. Keep up the great work, and I look forward to your revised submission! 🚀
✨ 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,21 @@ | |||
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 defined as a class variable. This means it will be shared across all instances of the Person
class. If this is not the intended behavior, consider using an instance variable instead.
app/main.py
Outdated
|
||
|
||
def create_person_list(people: list) -> list: | ||
# write your code here | ||
pass | ||
for peoples in 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 variable name peoples
is misleading as it suggests a plural form. Consider renaming it to person_data
or something similar to better reflect its purpose.
app/main.py
Outdated
pass | ||
for peoples in people: | ||
Person(peoples["name"], peoples["age"]) | ||
for peoples in 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.
Similar to line 11, the variable name peoples
is misleading. Consider renaming it to person_data
or something similar.
app/main.py
Outdated
for peoples in people: | ||
result_people = Person.people[peoples["name"]] | ||
if "wife" in peoples and peoples["wife"] is not None: | ||
result_people.wife = Person.people[peoples["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.
The code assumes that the wife
key in the dictionary corresponds to a valid name in the Person.people
dictionary. Ensure that the input data is validated or handle potential KeyError
exceptions.
app/main.py
Outdated
result_people.wife = Person.people[peoples["wife"]] | ||
|
||
if "husband" in peoples and peoples["husband"] is not None: | ||
result_people.husband = Person.people[peoples["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 line 16, ensure that the husband
key corresponds to a valid name in the Person.people
dictionary to avoid KeyError
exceptions.
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 job on making improvements to your code! 🎉 While there are still some critical issues to address, such as handling potential KeyError
exceptions for wife
and husband
keys and considering the use of instance variables instead of class variables for people
, your efforts are commendable. The decision to approve is made to help you move forward with your learning journey. Please review the comments and ensure these issues are addressed in future iterations to enhance the robustness and functionality of your code. 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 result and result["wife"] is not None: | ||
result_people.wife = Person.people[result["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.
The code assumes that the wife
key will always correspond to a valid name in the Person.people
dictionary. This can lead to a KeyError
if the name is not found. Consider adding a check to ensure the name exists in the dictionary before accessing it.
if result["husband"] in Person.people: | ||
result_people.husband = Person.people[result["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.
While there is a check for the husband
key in the Person.people
dictionary, the code still assumes that the key will always correspond to a valid name. Ensure that the input data is validated or handle potential KeyError
exceptions appropriately.
@@ -1,8 +1,22 @@ | |||
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 defined as a class variable, which means it is shared across all instances of the Person
class. If this shared behavior is not intended, consider using an instance variable instead to avoid potential issues.
No description provided.