Pyupgrade to Python 3.9 (#4718)

* Pyupgrade to Python 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Christian Clauss
2021-09-07 13:37:03 +02:00
committed by GitHub
parent 5d5831bdd0
commit cecf43d648
142 changed files with 523 additions and 530 deletions

View File

@ -4,8 +4,6 @@ https://en.wikipedia.org/wiki/Best-first_search#Greedy_BFS
from __future__ import annotations
from typing import Optional
Path = list[tuple[int, int]]
grid = [
@ -44,7 +42,7 @@ class Node:
goal_x: int,
goal_y: int,
g_cost: float,
parent: Optional[Node],
parent: Node | None,
):
self.pos_x = pos_x
self.pos_y = pos_y
@ -93,7 +91,7 @@ class GreedyBestFirst:
self.reached = False
def search(self) -> Optional[Path]:
def search(self) -> Path | None:
"""
Search for the path,
if a path is not found, only the starting position is returned
@ -156,7 +154,7 @@ class GreedyBestFirst:
)
return successors
def retrace_path(self, node: Optional[Node]) -> Path:
def retrace_path(self, node: Node | None) -> Path:
"""
Retrace the path from parents to parents until start node
"""