Skip to content

Commit

Permalink
fix(edge): use dynamic keyword attributes for init
Browse files Browse the repository at this point in the history
  • Loading branch information
mingrammer committed Mar 10, 2020
1 parent db585bf commit ecec971
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,7 @@ def __init__(
label: str = "",
color: str = "",
style: str = "",
fontcolor: str = "",
fontname: str = "",
fontsize: str = "",
**attrs: Dict,
):
"""Edge represents an edge between two nodes.
Expand Down Expand Up @@ -444,12 +442,7 @@ def __init__(
self._attrs["xlabel"] = label
self._attrs["color"] = color
self._attrs["style"] = style
if fontcolor:
self._attrs["fontcolor"] = fontcolor
if fontname:
self._attrs["fontname"] = fontname
if fontsize:
self._attrs["fontsize"] = fontsize
self._attrs.update(attrs)

def __sub__(self, other: Union["Node", "Edge", List["Node"]]):
"""Implement Self - Node or Edge and Self - [Nodes]"""
Expand Down Expand Up @@ -481,9 +474,9 @@ def append(self, other: Union[List["Node"], List["Edge"]], forward=None, reverse
result = []
for o in other:
if isinstance(o, Edge):
o.forward = forward if forward is not None else o.forward
o.reverse = forward if forward is not None else o.reverse
self._attrs = o._attrs.copy()
o.forward = forward if forward else o.forward
o.reverse = forward if forward else o.reverse
self._attrs = o.attrs.copy()
result.append(o)
else:
result.append(Edge(o, forward=forward, reverse=reverse, **self._attrs))
Expand Down

0 comments on commit ecec971

Please sign in to comment.