refactor: Follow the PEP 585 Typing standard (#439)

* Follow the PEP 585 Typing standard

* Update list.py
This commit is contained in:
Yudong Jin
2023-03-23 18:51:56 +08:00
committed by GitHub
parent f4e01ea32e
commit 8918ec9079
43 changed files with 256 additions and 342 deletions

View File

@ -8,8 +8,7 @@ import sys, os.path as osp
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
def pre_order(root: Optional[TreeNode]) -> None:
def pre_order(root: TreeNode | None) -> None:
""" 前序遍历 """
if root is None:
return
@ -18,7 +17,7 @@ def pre_order(root: Optional[TreeNode]) -> None:
pre_order(root=root.left)
pre_order(root=root.right)
def in_order(root: Optional[TreeNode]) -> None:
def in_order(root: TreeNode | None) -> None:
""" 中序遍历 """
if root is None:
return
@ -27,7 +26,7 @@ def in_order(root: Optional[TreeNode]) -> None:
res.append(root.val)
in_order(root=root.right)
def post_order(root: Optional[TreeNode]) -> None:
def post_order(root: TreeNode | None) -> None:
""" 后序遍历 """
if root is None:
return