chore: apply pre-commit hooks

This commit is contained in:
Xyphuz 2022-05-25 17:16:10 +08:00
parent 3d0a608896
commit e8ed141c09
2 changed files with 7 additions and 5 deletions

View file

@ -2,7 +2,7 @@ exclude: |
(?x)^( (?x)^(
README.md| README.md|
LICENSE| LICENSE|
tests/ymls/ tests/ymls/others/
) )
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks

View file

@ -1,3 +1,5 @@
from typing import Optional
import graphviz import graphviz
from compose_viz.compose import Compose from compose_viz.compose import Compose
@ -38,11 +40,11 @@ def apply_edge_style(type) -> dict:
"depends_on": { "depends_on": {
"style": "dotted", "style": "dotted",
}, },
"extends":{ "extends": {
"dir": "both", "dir": "both",
"arrowhead": "inv", "arrowhead": "inv",
"arrowtail": "dot", "arrowtail": "dot",
} },
} }
return style[type] return style[type]
@ -60,10 +62,10 @@ class Graph:
transTable = name.maketrans({":": ""}) transTable = name.maketrans({":": ""})
return name.translate(transTable) return name.translate(transTable)
def add_vertex(self, name: str, type: str, lable: str = None) -> None: def add_vertex(self, name: str, type: str, lable: Optional[str] = None) -> None:
self.dot.node(self.validate_name(name), lable, **apply_vertex_style(type)) self.dot.node(self.validate_name(name), lable, **apply_vertex_style(type))
def add_edge(self, head: str, tail: str, type: str, lable: str = None) -> None: def add_edge(self, head: str, tail: str, type: str, lable: Optional[str] = None) -> None:
self.dot.edge(self.validate_name(head), self.validate_name(tail), lable, **apply_edge_style(type)) self.dot.edge(self.validate_name(head), self.validate_name(tail), lable, **apply_edge_style(type))
def render(self, format: str, cleanup: bool = True) -> None: def render(self, format: str, cleanup: bool = True) -> None: