London | 26-SDC-Mar | Jamal Laqdiem| Sprint 2 | implement a linked list in py - #211
Open
jamallaqdiem wants to merge 3 commits into
Open
London | 26-SDC-Mar | Jamal Laqdiem| Sprint 2 | implement a linked list in py#211jamallaqdiem wants to merge 3 commits into
jamallaqdiem wants to merge 3 commits into
Conversation
cjyuan
reviewed
Jul 9, 2026
Comment on lines
+4
to
+8
| @dataclass(slots=True) | ||
| class Node: | ||
| value: Any | ||
| next: Optional['Node'] = None | ||
| previous: Optional['Node'] = None |
There was a problem hiding this comment.
Good use of dataclass
Suggestion: Explore Python Generic next.
Comment on lines
+37
to
+39
| def remove(self, node_handle: Optional[Node]) -> None: | ||
| if not node_handle: | ||
| return |
There was a problem hiding this comment.
Why append a handle suffix to the parameter name? Why make the parameter optional?
Author
There was a problem hiding this comment.
Hi sorry I wrote the comment but didn't click to send,
- I made the parameter Optional in case a caller passes a None value, the method can handle it with an early return instead of crash.
- I added the handle suffix as a signal to anyone using this method that expect the Node object instance, instead of a string or int.
There was a problem hiding this comment.
If the type hint on the parameter is Node, wouldn't the type checker report an error when the method is called without any parameter?
Author
There was a problem hiding this comment.
that's true, since the type checker enforces Node, making it Optional is redundant, and the _handle suffix is unnecessary.
|
Could you also address this comment; #211 (comment) ? |
|
All good. Well done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Self checklist
Changelist
Completed implementing a linked list in python, using a O(1) worst-case time complexity.