ref: Apply ruff rules FURB110 and RUF046 (#5093)
Apply rules FURB110 and RUF046
This commit is contained in:
parent
9270f1a0f8
commit
b98614ca5b
2 changed files with 11 additions and 11 deletions
|
|
@ -93,7 +93,7 @@ class FlowToolComponent(LCToolComponent):
|
||||||
except Exception: # noqa: BLE001
|
except Exception: # noqa: BLE001
|
||||||
logger.opt(exception=True).warning("Failed to set run_id")
|
logger.opt(exception=True).warning("Failed to set run_id")
|
||||||
inputs = get_flow_inputs(graph)
|
inputs = get_flow_inputs(graph)
|
||||||
tool_description = self.tool_description.strip() if self.tool_description.strip() else flow_data.description
|
tool_description = self.tool_description.strip() or flow_data.description
|
||||||
tool = FlowTool(
|
tool = FlowTool(
|
||||||
name=self.tool_name,
|
name=self.tool_name,
|
||||||
description=tool_description,
|
description=tool_description,
|
||||||
|
|
|
||||||
|
|
@ -90,11 +90,11 @@ class AsciiCanvas:
|
||||||
self.point(x0, y0, char)
|
self.point(x0, y0, char)
|
||||||
elif abs(dx) >= abs(dy):
|
elif abs(dx) >= abs(dy):
|
||||||
for x in range(x0, x1 + 1):
|
for x in range(x0, x1 + 1):
|
||||||
y = y0 + int(round((x - x0) * dy / float(dx))) if dx else y0
|
y = y0 + round((x - x0) * dy / float(dx)) if dx else y0
|
||||||
self.point(x, y, char)
|
self.point(x, y, char)
|
||||||
else:
|
else:
|
||||||
for y in range(min(y0, y1), max(y0, y1) + 1):
|
for y in range(min(y0, y1), max(y0, y1) + 1):
|
||||||
x = x0 + int(round((y - y0) * dx / float(dy))) if dy else x0
|
x = x0 + round((y - y0) * dx / float(dy)) if dy else x0
|
||||||
self.point(x, y, char)
|
self.point(x, y, char)
|
||||||
|
|
||||||
def text(self, x, y, text) -> None:
|
def text(self, x, y, text) -> None:
|
||||||
|
|
@ -171,8 +171,8 @@ def draw_graph(vertexes, edges, *, return_ascii=True):
|
||||||
maxx = max(xlist)
|
maxx = max(xlist)
|
||||||
maxy = max(ylist)
|
maxy = max(ylist)
|
||||||
|
|
||||||
canvas_cols = int(math.ceil(maxx - minx)) + 1
|
canvas_cols = math.ceil(maxx - minx) + 1
|
||||||
canvas_lines = int(round(maxy - miny))
|
canvas_lines = round(maxy - miny)
|
||||||
|
|
||||||
canvas = AsciiCanvas(canvas_cols, canvas_lines)
|
canvas = AsciiCanvas(canvas_cols, canvas_lines)
|
||||||
|
|
||||||
|
|
@ -184,18 +184,18 @@ def draw_graph(vertexes, edges, *, return_ascii=True):
|
||||||
start = edge.view._pts[index - 1]
|
start = edge.view._pts[index - 1]
|
||||||
end = edge.view._pts[index]
|
end = edge.view._pts[index]
|
||||||
canvas.line(
|
canvas.line(
|
||||||
int(round(start[0] - minx)),
|
round(start[0] - minx),
|
||||||
int(round(start[1] - miny)),
|
round(start[1] - miny),
|
||||||
int(round(end[0] - minx)),
|
round(end[0] - minx),
|
||||||
int(round(end[1] - miny)),
|
round(end[1] - miny),
|
||||||
"*",
|
"*",
|
||||||
)
|
)
|
||||||
|
|
||||||
for vertex in sug.g.sV:
|
for vertex in sug.g.sV:
|
||||||
x = vertex.view.xy[0] - vertex.view.w / 2.0
|
x = vertex.view.xy[0] - vertex.view.w / 2.0
|
||||||
y = vertex.view.xy[1]
|
y = vertex.view.xy[1]
|
||||||
canvas.box(int(round(x - minx)), int(round(y - miny)), vertex.view.w, vertex.view.h)
|
canvas.box(round(x - minx), round(y - miny), vertex.view.w, vertex.view.h)
|
||||||
canvas.text(int(round(x - minx)) + 1, int(round(y - miny)) + 1, vertex.data)
|
canvas.text(round(x - minx) + 1, round(y - miny) + 1, vertex.data)
|
||||||
if return_ascii:
|
if return_ascii:
|
||||||
return canvas.draws()
|
return canvas.draws()
|
||||||
canvas.draw()
|
canvas.draw()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue