Solution#1827
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because your ActorManager.create method does not fulfill its declared contract and the task requirement that it return the created Actor instance. In app/managers.py, the method is annotated as def create(self, first_name: str, last_name: str) -> Actor: but currently performs the INSERT and commit without returning anything, so callers expecting an Actor will receive None, which breaks the expected functionality. To fix this, after executing the INSERT, retrieve the new row’s id (for example, via cursor.lastrowid), then construct an Actor with that id, first_name, and last_name, and return that instance. This aligns with the description that create "creates a new entry in the table" and yields an Actor representing the newly inserted row.
Apart from this issue, your dataclass definition in models.py and the other CRUD methods (all, update, delete) in ActorManager look consistent with the requirements and follow the expected patterns. As a minor improvement (not required for this task), you might later consider adding a way to close the DB connection cleanly, such as a dedicated close method or context manager support, to improve resource handling. Once you adjust create to return the new Actor instance, your solution will meet the core functional requirements for this assignment. Keep going—you’re very close; this is a good opportunity to practice aligning type hints and method behavior with the specification.
✨ 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
| def create(self, first_name: str, last_name: str) -> Actor: | ||
| self._connection.execute( | ||
| f"INSERT INTO {self.table_name} (first_name, last_name) " | ||
| f"VALUES (?, ?)", (first_name, last_name) | ||
| ) | ||
| self._connection.commit() |
There was a problem hiding this comment.
create is annotated to return Actor, but it doesn't return anything. This violates the description requirement that the create method "creates a new entry in the table" with given properties and, per the method signature, should yield an Actor instance; consider retrieving the inserted id and returning an Actor built from id, first_name, and last_name.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved because it cleanly meets all of the functional and checklist requirements for this task. The Actor dataclass is correctly defined with id, first_name, and last_name, and ActorManager is properly initialized with db_name and table_name while creating the SQLite connection inside __init__ as required. All CRUD methods behave as specified: create inserts a row and returns a fully constructed Actor, all returns a list of Actor instances (or an empty list when the table has no rows), and update/delete correctly apply changes using the provided primary key. There are no critical blockers such as missing features, broken behavior, or checklist violations, and you’ve fixed the earlier issue where create did not return an Actor. As a minor, non-blocking suggestion, you could consider adding a method to cleanly close the database connection when the manager is no longer needed, but this isn’t required for passing the task. Overall, this is a solid, straightforward implementation that satisfies the assignment’s expectations.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.