瀏覽代碼

refactor: use `None` for `dict` default values (#831)

pull/439/head
Viicos 1 年之前
committed by GitHub
父節點
當前提交
40ee32e065
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 1 個文件被更改,包括 13 次插入5 次删除
  1. +13
    -5
      diagrams/__init__.py

+ 13
- 5
diagrams/__init__.py 查看文件

@@ -2,7 +2,7 @@ import contextvars
import os
import uuid
from pathlib import Path
from typing import List, Union, Dict
from typing import Dict, List, Optional, Union

from graphviz import Digraph

@@ -86,9 +86,9 @@ class Diagram:
autolabel: bool = False,
show: bool = True,
strict: bool = False,
graph_attr: dict = {},
node_attr: dict = {},
edge_attr: dict = {},
graph_attr: Optional[dict] = None,
node_attr: Optional[dict] = None,
edge_attr: Optional[dict] = None,
):
"""Diagram represents a global diagrams context.

@@ -105,6 +105,12 @@ class Diagram:
:param edge_attr: Provide edge_attr dot config attributes.
:param strict: Rendering should merge multi-edges.
"""
if graph_attr is None:
graph_attr = {}
if node_attr is None:
node_attr = {}
if edge_attr is None:
edge_attr = {}
self.name = name
if not name and not filename:
filename = "diagrams_image"
@@ -215,7 +221,7 @@ class Cluster:
self,
label: str = "cluster",
direction: str = "LR",
graph_attr: dict = {},
graph_attr: Optional[dict] = None,
):
"""Cluster represents a cluster context.

@@ -223,6 +229,8 @@ class Cluster:
:param direction: Data flow direction. Default is 'left to right'.
:param graph_attr: Provide graph_attr dot config attributes.
"""
if graph_attr is None:
graph_attr = {}
self.label = label
self.name = "cluster_" + self.label



Loading…
取消
儲存