Skip to content

London | 26-SDC-Mar | Jamal Laqdiem| Sprint 2 | implement a linked list in py - #211

Open
jamallaqdiem wants to merge 3 commits into
CodeYourFuture:mainfrom
jamallaqdiem:linked_list
Open

London | 26-SDC-Mar | Jamal Laqdiem| Sprint 2 | implement a linked list in py#211
jamallaqdiem wants to merge 3 commits into
CodeYourFuture:mainfrom
jamallaqdiem:linked_list

Conversation

@jamallaqdiem

Copy link
Copy Markdown

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Completed implementing a linked list in python, using a O(1) worst-case time complexity.

@jamallaqdiem jamallaqdiem added Module-Complexity The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 7, 2026
Comment on lines +4 to +8
@dataclass(slots=True)
class Node:
value: Any
next: Optional['Node'] = None
previous: Optional['Node'] = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why append a handle suffix to the parameter name? Why make the parameter optional?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi sorry I wrote the comment but didn't click to send,

  1. 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.
  2. 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's true, since the type checker enforces Node, making it Optional is redundant, and the _handle suffix is unnecessary.

Comment thread Sprint-2/implement_linked_list/linked_list.py Outdated
@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 9, 2026
@jamallaqdiem jamallaqdiem added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 9, 2026
@cjyuan

cjyuan commented Jul 9, 2026

Copy link
Copy Markdown

Could you also address this comment; #211 (comment) ?

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 9, 2026
@jamallaqdiem jamallaqdiem added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 13, 2026
@jamallaqdiem jamallaqdiem added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 13, 2026
@cjyuan

cjyuan commented Jul 13, 2026

Copy link
Copy Markdown

All good. Well done.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Complexity The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants