Skip to content

Commit

Permalink
refactor: use None for dict default values (mingrammer#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos authored and ajmaradiaga committed Nov 8, 2023
1 parent d4c7612 commit acbd0de
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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

Expand Down Expand Up @@ -86,9 +86,9 @@ def __init__(
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.
Expand All @@ -105,6 +105,12 @@ def __init__(
: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"
Expand Down Expand Up @@ -215,14 +221,16 @@ def __init__(
self,
label: str = "cluster",
direction: str = "LR",
graph_attr: dict = {},
graph_attr: Optional[dict] = None,
):
"""Cluster represents a cluster context.
:param label: Cluster label.
: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

Expand Down

0 comments on commit acbd0de

Please sign in to comment.