Bläddra i källkod

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

pull/439/head
Viicos 1 år sedan
committed by GitHub
förälder
incheckning
40ee32e065
Ingen känd nyckel hittad för denna signaturen i databasen GPG-nyckel ID: 4AEE18F83AFDEB23
1 ändrade filer med 13 tillägg och 5 borttagningar
  1. +13
    -5
      diagrams/__init__.py

+ 13
- 5
diagrams/__init__.py Visa fil

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



Laddar…
Avbryt
Spara