Add flake8-builtins to pre-commit and fix errors (#7105)

Ignore `A003`

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
This commit is contained in:
Caeden
2022-10-13 15:23:59 +01:00
committed by GitHub
parent e661b98829
commit d5a9f649b8
31 changed files with 113 additions and 106 deletions

View File

@ -40,10 +40,10 @@ def search(
else: # to choose the least costliest action so as to move closer to the goal
cell.sort()
cell.reverse()
next = cell.pop()
x = next[2]
y = next[3]
g = next[1]
next_cell = cell.pop()
x = next_cell[2]
y = next_cell[3]
g = next_cell[1]
if x == goal[0] and y == goal[1]:
found = True

View File

@ -56,8 +56,8 @@ def dijkstra(graph, start, end):
for v, c in graph[u]:
if v in visited:
continue
next = cost + c
heapq.heappush(heap, (next, v))
next_item = cost + c
heapq.heappush(heap, (next_item, v))
return -1

View File

@ -72,22 +72,22 @@ def compute_bridges(graph: dict[int, list[int]]) -> list[tuple[int, int]]:
[]
"""
id = 0
id_ = 0
n = len(graph) # No of vertices in graph
low = [0] * n
visited = [False] * n
def dfs(at, parent, bridges, id):
def dfs(at, parent, bridges, id_):
visited[at] = True
low[at] = id
id += 1
low[at] = id_
id_ += 1
for to in graph[at]:
if to == parent:
pass
elif not visited[to]:
dfs(to, at, bridges, id)
dfs(to, at, bridges, id_)
low[at] = min(low[at], low[to])
if id <= low[to]:
if id_ <= low[to]:
bridges.append((at, to) if at < to else (to, at))
else:
# This edge is a back edge and cannot be a bridge
@ -96,7 +96,7 @@ def compute_bridges(graph: dict[int, list[int]]) -> list[tuple[int, int]]:
bridges: list[tuple[int, int]] = []
for i in range(n):
if not visited[i]:
dfs(i, -1, bridges, id)
dfs(i, -1, bridges, id_)
return bridges

View File

@ -13,7 +13,7 @@ from collections.abc import Iterator
class Vertex:
"""Class Vertex."""
def __init__(self, id):
def __init__(self, id_):
"""
Arguments:
id - input an id to identify the vertex
@ -21,7 +21,7 @@ class Vertex:
neighbors - a list of the vertices it is linked to
edges - a dict to store the edges's weight
"""
self.id = str(id)
self.id = str(id_)
self.key = None
self.pi = None
self.neighbors = []