Skip to content

Commit 504ce68

Browse files
yt-msMidnighter
authored andcommitted
docs(model): fix flake8 warnings
1 parent 8e190dc commit 504ce68

File tree

7 files changed

+24
-34
lines changed

7 files changed

+24
-34
lines changed

src/structurizr/model/container_instance.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@
3636

3737

3838
class ContainerInstanceIO(DeploymentElementIO):
39-
"""
40-
Represents a container instance which can be added to a deployment node.
41-
42-
Attributes:
43-
44-
"""
39+
"""Represents a container instance which can be added to a deployment node."""
4540

4641
container: "ContainerIO"
4742
container_id: str
@@ -50,12 +45,7 @@ class ContainerInstanceIO(DeploymentElementIO):
5045

5146

5247
class ContainerInstance(DeploymentElement):
53-
"""
54-
Represents a container instance which can be added to a deployment node.
55-
56-
Attributes:
57-
58-
"""
48+
"""Represents a container instance which can be added to a deployment node."""
5949

6050
def __init__(
6151
self,

src/structurizr/model/deployment_node.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,15 @@
2525

2626

2727
class DeploymentNodeIO(DeploymentElementIO):
28-
"""
29-
Represent a deployment node.
30-
31-
Attributes:
32-
33-
"""
28+
"""Represent a deployment node."""
3429

3530
parent: "DeploymentNodeIO"
3631
technology: str = ""
3732
instances: int = 1
3833

3934

4035
class DeploymentNode(DeploymentElement):
41-
"""
42-
Represent a deployment node.
43-
44-
Attributes:
45-
46-
"""
36+
"""Represent a deployment node."""
4737

4838
def __init__(
4939
self,
@@ -65,7 +55,7 @@ def __init__(
6555

6656
@classmethod
6757
def hydrate(cls, deployment_node_io: DeploymentNodeIO) -> "DeploymentNode":
68-
""""""
58+
"""Hydrate a new DeploymentNode instance from its IO."""
6959
# TODO (midnighter): Initialization requires `parent`.
7060
return cls(
7161
# parent=deployment_node_io.parent,

src/structurizr/model/element.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ def __init__(
7272
self.name = name
7373
self.description = description
7474
self.url = url
75-
# Note: relationships should always match get_efferent_relationships() - i.e. outbound relationships only
75+
# Note: relationships should always match get_efferent_relationships() - i.e.
76+
# outbound relationships only
7677
self.relationships: Iterable[Relationship] = set(relationships)
7778

7879
self.tags.add(Tags.ELEMENT)
@@ -108,9 +109,10 @@ def add_relationship(
108109
) -> Relationship:
109110
"""Add a new relationship from this element to another.
110111
111-
This can be used either to add a `Relationship` instance that has already been constructed,
112-
or by passing the arguments (e.g. description, destination) with which to construct a new
113-
one. The relationship will automatically be registered with the element's model.
112+
This can be used either to add a `Relationship` instance that has already been
113+
constructed, or by passing the arguments (e.g. description, destination) with
114+
which to construct a new one. The relationship will automatically be
115+
registered with the element's model.
114116
"""
115117
if relationship is None:
116118
relationship = Relationship(**kwargs)
@@ -120,7 +122,8 @@ def add_relationship(
120122
relationship.source = self
121123
elif relationship.source is not self:
122124
raise ValueError(
123-
f"Cannot add relationship {relationship} to element {self} that is not its source."
125+
f"Cannot add relationship {relationship} to element {self} that is "
126+
f"not its source."
124127
)
125128
self.relationships.add(relationship)
126129
self.model.add_relationship(
@@ -130,6 +133,7 @@ def add_relationship(
130133

131134
@classmethod
132135
def hydrate_arguments(cls, element_io: ElementIO) -> dict:
136+
"""Hydrate an ElementIO into the constructor arguments for Element."""
133137
return {
134138
**super().hydrate_arguments(element_io),
135139
"name": element_io.name,

src/structurizr/model/enterprise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ def __init__(self, *, name: str, **kwargs) -> None:
5353

5454
@classmethod
5555
def hydrate(cls, enterprise_io: EnterpriseIO) -> "Enterprise":
56-
""""""
56+
"""Hydrate a new Enterprise instance from its IO."""
5757
return cls(name=enterprise_io.name)

src/structurizr/model/model_item.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
from abc import ABC
20-
from typing import Dict, Iterable, List, Set, Union
20+
from typing import Dict, Iterable, List, Union
2121

2222
from ordered_set import OrderedSet
2323
from pydantic import Field, validator
@@ -49,12 +49,13 @@ class ModelItemIO(BaseModel, ABC):
4949

5050
@validator("tags", pre=True)
5151
def split_tags(cls, tags: Union[str, Iterable[str]]) -> List[str]:
52+
"""Convert comma-separated tag list into list if needed."""
5253
if isinstance(tags, str):
5354
return tags.split(",")
5455
return list(tags)
5556

5657
def dict(self, **kwargs) -> dict:
57-
""""""
58+
"""Map this IO into a dictionary suitable for serialisation."""
5859
obj = super().dict(**kwargs)
5960
if "tags" in obj:
6061
obj["tags"] = ",".join(obj["tags"])
@@ -82,18 +83,20 @@ def __init__(
8283
perspectives: Iterable[Perspective] = (),
8384
**kwargs,
8485
):
85-
""""""
86+
"""Initialise a ModelItem instance."""
8687
super().__init__(**kwargs)
8788
self.id = id
8889
self.tags = OrderedSet(tags)
8990
self.properties = dict(properties)
9091
self.perspectives = set(perspectives)
9192

9293
def __repr__(self) -> str:
94+
"""Return repr(self)."""
9395
return f"{type(self).__name__}(id={self.id})"
9496

9597
@classmethod
9698
def hydrate_arguments(cls, model_item_io: ModelItemIO) -> dict:
99+
"""Hydrate an ModelItemIO into the constructor arguments for ModelItem."""
97100
return {
98101
"id": model_item_io.id,
99102
"tags": model_item_io.tags,

src/structurizr/model/perspective.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,5 @@ def __init__(self, *, name: str, description: str, **kwargs) -> None:
7171

7272
@classmethod
7373
def hydrate(cls, perspective_io: PerspectiveIO) -> "Perspective":
74+
"""Hydrate a new Perspective instance from its IO."""
7475
return cls(name=perspective_io.name, description=perspective_io.description)

src/structurizr/model/static_structure_element.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def uses(
5757
technology: str = "",
5858
**kwargs,
5959
) -> Optional["Relationship"]:
60+
"""Add a unidirectional "uses" style relationship to another element."""
6061
return self.get_model().add_relationship(
6162
source=self,
6263
destination=destination,
@@ -72,6 +73,7 @@ def delivers(
7273
technology: str = "",
7374
**kwargs,
7475
) -> Optional["Relationship"]:
76+
"""Add a unidirectional relationship to another element."""
7577
return self.uses(
7678
destination=destination,
7779
description=description,

0 commit comments

Comments
 (0)