Przeglądaj źródła

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

pull/439/head
Viicos 1 rok temu
committed by GitHub
rodzic
commit
40ee32e065
Nie znaleziono w bazie danych klucza dla tego podpisu ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 13 dodań i 5 usunięć
  1. +13
    -5
      diagrams/__init__.py

+ 13
- 5
diagrams/__init__.py Wyświetl plik

@@ -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



Ładowanie…
Anuluj
Zapisz