diff --git a/data_structures/linked_list/merge_sort_linked_list.py b/data_structures/linked_list/merge_sort_linked_list.py index ec8ce7f89..f72fe3ee8 100644 --- a/data_structures/linked_list/merge_sort_linked_list.py +++ b/data_structures/linked_list/merge_sort_linked_list.py @@ -47,6 +47,8 @@ def get_middle(head: Node | None) -> Node | None: slow: Node | None = head fast: Node | None = head while fast is not None and fast.next is not None: + if slow is None: # This should never happen, but it satisfies the type checker + return None slow = slow.next fast = fast.next.next