'Solution'#1817
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because there are a few critical points that conflict with the task requirements and checklist.
Critical issues that must be fixed (blockers):
- In
app/managers.py, the methodallis annotated as-> None(around the method definition line) but it actually returnslist[Actor]. The requirement saysallmust return a list ofActor(or an empty list), so the annotation is misleading; update it to something likedef all(self) -> list[Actor]:or remove the annotation so it matches the behavior. - In
app/managers.py, inside thedeletemethod, you callcursor.execute("DELETE ...")but never callself._connection.commit()afterward. This means deletions may not be persisted, and for consistent CRUD behavior (matchingcreateandupdate), you need to addself._connection.commit()at the end ofdelete. - At the bottom of
app/managers.py, you have top-level code like:This creates a real SQLite file on import and violates the “Don’t push db files” checklist rule [CHECKLIST ITEM #1]. For the task,manager = ActorManager("actor_db.sqlite", "actors") manager.delete("1") print(manager.all())
managers.pyshould only defineActorManagerand related logic, so remove this block (or move it underif __name__ == "__main__":for personal testing, but it should not be part of the submitted solution).
Once you fix the return type of all, add the missing commit in delete, and remove the side-effectful bottom-of-file code that creates actor_db.sqlite, your solution will align well with the requirements. The core structure and CRUD logic are otherwise solid, so these changes will complete a good implementation.
✨ 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
| ) | ||
| self._connection.commit() | ||
|
|
||
| def all(self) -> None: |
There was a problem hiding this comment.
all is annotated as returning None, but it actually returns a list of Actor instances; update the return type (e.g., -> list[Actor]) or remove the annotation so it matches the behavior required by the task.
| ) | ||
| self._connection.commit() | ||
|
|
||
| def delete(self, pk: int) -> None: |
There was a problem hiding this comment.
delete executes a DELETE but never commits the transaction, unlike create and update; add self._connection.commit() so deletions are persisted as required for correct CRUD behavior.
| f"where id = ?", (pk,)) | ||
|
|
||
|
|
||
| manager = ActorManager("actor_db.sqlite", "actors") |
There was a problem hiding this comment.
This top-level code creates a real SQLite file (actor_db.sqlite) and runs operations on import; for the task, managers.py should only define ActorManager, and this pattern risks violating the checklist item about not pushing DB files—remove this block or move it under a guarded if __name__ == "__main__": used only locally.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved because it fully meets the functional and structural requirements for this task. The Actor dataclass is correctly defined with id, first_name, and last_name, and lives in models.py as required. The ActorManager in managers.py correctly accepts db_name and table_name in __init__, creates the SQLite connection there, and ensures the CRUD methods (create, all, update, delete) behave as expected and commit their changes. The all() method returns a list[Actor] and properly handles the empty-table case, and there is no side-effectful top-level code creating a database file, which keeps you compliant with the checklist about not pushing .db files. The table name passed in tests is plural ("actors"), and your manager class name is singular (ActorManager), matching the naming conventions.
Nice work aligning your code with both the specification and the earlier review feedback; this implementation should pass the provided tests and is ready to move forward.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.