From 7cbe284fcf676868b3500584bb829a1f8bb8e971 Mon Sep 17 00:00:00 2001 From: Qingpeng Li <43924785+qingpeng9802@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:41:02 +0800 Subject: [PATCH] follow PEP585 typing (#767) Signed-off-by: Qingpeng Li --- docs/chapter_array_and_linkedlist/linked_list.md | 6 +++--- docs/chapter_computational_complexity/space_complexity.md | 2 +- docs/chapter_tree/avl_tree.md | 4 ++-- docs/chapter_tree/binary_tree.md | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/chapter_array_and_linkedlist/linked_list.md b/docs/chapter_array_and_linkedlist/linked_list.md index ad0f27c3..fa88fa81 100755 --- a/docs/chapter_array_and_linkedlist/linked_list.md +++ b/docs/chapter_array_and_linkedlist/linked_list.md @@ -23,7 +23,7 @@ """链表节点类""" def __init__(self, val: int): self.val: int = val # 节点值 - self.next: Optional[ListNode] = None # 指向下一节点的引用 + self.next: ListNode | None = None # 指向下一节点的引用 ``` === "C++" @@ -740,8 +740,8 @@ """双向链表节点类""" def __init__(self, val: int): self.val: int = val # 节点值 - self.next: Optional[ListNode] = None # 指向后继节点的引用 - self.prev: Optional[ListNode] = None # 指向前驱节点的引用 + self.next: ListNode | None = None # 指向后继节点的引用 + self.prev: ListNode | None = None # 指向前驱节点的引用 ``` === "C++" diff --git a/docs/chapter_computational_complexity/space_complexity.md b/docs/chapter_computational_complexity/space_complexity.md index bb952edf..3229534e 100755 --- a/docs/chapter_computational_complexity/space_complexity.md +++ b/docs/chapter_computational_complexity/space_complexity.md @@ -29,7 +29,7 @@ """类""" def __init__(self, x: int): self.val: int = x # 节点值 - self.next: Optional[Node] = None # 指向下一节点的引用 + self.next: Node | None = None # 指向下一节点的引用 def function() -> int: """函数""" diff --git a/docs/chapter_tree/avl_tree.md b/docs/chapter_tree/avl_tree.md index 2b0271c8..63324e7f 100644 --- a/docs/chapter_tree/avl_tree.md +++ b/docs/chapter_tree/avl_tree.md @@ -28,8 +28,8 @@ AVL 树既是二叉搜索树也是平衡二叉树,同时满足这两类二叉 def __init__(self, val: int): self.val: int = val # 节点值 self.height: int = 0 # 节点高度 - self.left: Optional[TreeNode] = None # 左子节点引用 - self.right: Optional[TreeNode] = None # 右子节点引用 + self.left: TreeNode | None = None # 左子节点引用 + self.right: TreeNode | None = None # 右子节点引用 ``` === "C++" diff --git a/docs/chapter_tree/binary_tree.md b/docs/chapter_tree/binary_tree.md index fc9e6e4e..408a7509 100644 --- a/docs/chapter_tree/binary_tree.md +++ b/docs/chapter_tree/binary_tree.md @@ -9,8 +9,8 @@ """二叉树节点类""" def __init__(self, val: int): self.val: int = val # 节点值 - self.left: Optional[TreeNode] = None # 左子节点引用 - self.right: Optional[TreeNode] = None # 右子节点引用 + self.left: TreeNode | None = None # 左子节点引用 + self.right: TreeNode | None = None # 右子节点引用 ``` === "C++"