-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Update main.py #2335
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
base: master
Are you sure you want to change the base?
Update main.py #2335
Conversation
mateacademy-ai-mentor
left a comment
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.
Review Summary
Great job implementing the core logic! The two-pass approach works well, and you've successfully created and linked the Person instances. However, this submission requires changes because it doesn't follow several key guidelines from the project checklist, which are important requirements for this task. Please address the following points:
- Use List Comprehension: The initial creation of
Personobjects should be done with a list comprehension instead of aforloop, as required by [CHECKLIST ITEM #3]. - Improve Conditional Logic: The checks for spouses use
if "key" in dataand nestedifstatements. Please refactor this to use thedict.get()method and combine conditions into a singleifstatement. This addresses [CHECKLIST ITEM #2] and [CHECKLIST ITEM #4].
Making these changes will bring your code in line with the project's standards. I'm looking forward to your next submission!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
app/main.py
Outdated
| for data in people_data: | ||
| name = str(data["name"]) | ||
| age = int(data["age"]) | ||
| person = Person(name, age) | ||
| persons.append(person) |
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.
This violates checklist item #3: 'When creating a list of instances from a collection (such as a list of dictionaries), it is recommended to use list comprehension rather than traditional for loops.' This entire block can be replaced with a more concise list comprehension.
app/main.py
Outdated
| if "wife" in data and data["wife"] is not None: | ||
| wife_name = str(data["wife"]) | ||
| if wife_name in Person.people: | ||
| person.wife = Person.people[wife_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.
This block violates two checklist items. It violates checklist #4 by checking for a key with "wife" in data instead of using the recommended data.get('wife'). It also violates checklist #2 by using a nested if statement on line 30. These conditions can be combined into a single if statement using and for a cleaner approach.
app/main.py
Outdated
| if "husband" in data and data["husband"] is not None: | ||
| husband_name = str(data["husband"]) | ||
| if husband_name in Person.people: | ||
| person.husband = Person.people[husband_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.
mateacademy-ai-mentor
left a comment
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.
Review Summary
Excellent work on this revision! I am approving your solution as you've successfully addressed all the previous feedback and met all the project requirements. The logic is clear, and your use of list comprehension and dict.get() is implemented perfectly.
The automated checks have flagged a minor linting issue in app/main.py on line 13, where a docstring is slightly too long. You can easily fix this by shortening the text to be under 79 characters. This is just a style note and doesn't affect the approval. Well done!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.