Skip to content

Commit 45144e8

Browse files
committed
typing
1 parent 94ebc33 commit 45144e8

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/compas_dem/interactions/contact.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from typing import Annotated
2+
from typing import Optional
3+
from typing import Union
24

35
from compas.geometry import Frame
46
from compas.geometry import Line
@@ -93,7 +95,7 @@ def __init__(self, forces=None, **kwargs):
9395

9496
self._points2 = None
9597
self._polygon2 = None
96-
self._forces = forces
98+
self._forces = forces or []
9799

98100
self._compressiondata = None
99101
self._tensiondata = None
@@ -131,7 +133,7 @@ def M0(self) -> float:
131133
m0 = 0
132134
for a, b in pairwise(self.points2 + self.points2[:1]):
133135
d = b - a
134-
n = [d[1], -d[0], 0]
136+
n = [d[1], -d[0], 0] # type: ignore
135137
m0 += dot_vectors(a, n)
136138
return 0.5 * m0
137139

@@ -140,7 +142,7 @@ def M1(self) -> Point:
140142
m1 = Point(0, 0, 0)
141143
for a, b in pairwise(self.points2 + self.points2[:1]):
142144
d = b - a
143-
n = [d[1], -d[0], 0]
145+
n = [d[1], -d[0], 0] # type: ignore
144146
m0 = dot_vectors(a, n)
145147
m1 += (a + b) * m0
146148
return m1 / 6
@@ -150,7 +152,7 @@ def M2(self) -> Annotated[list[Annotated[list[float], 3]], 3]:
150152
m2 = outer_product([0, 0, 0], [0, 0, 0])
151153
for a, b in pairwise(self.points2 + self.points2[:1]):
152154
d = b - a
153-
n = [d[1], -d[0], 0]
155+
n = [d[1], -d[0], 0] # type: ignore
154156
m0 = dot_vectors(a, n)
155157
aa = outer_product(a, a)
156158
ab = outer_product(a, b)
@@ -163,7 +165,7 @@ def M2(self) -> Annotated[list[Annotated[list[float], 3]], 3]:
163165
m0,
164166
),
165167
)
166-
return scale_matrix(m2, 1 / 12.0)
168+
return scale_matrix(m2, 1 / 12.0) # type: ignore
167169

168170
@property
169171
def kern(self):
@@ -267,7 +269,7 @@ def frictiondata(self) -> list[list[float]]:
267269
return self._frictiondata
268270

269271
@property
270-
def resultantpoint(self) -> list[float]:
272+
def resultantpoint(self) -> Optional[Union[Point, list[float]]]:
271273
if not self.forces:
272274
return []
273275
normalcomponents = [f["c_np"] - f["c_nn"] for f in self.forces]
@@ -291,7 +293,7 @@ def resultantforce(self) -> list[Line]:
291293
return [Line(p1, p2)]
292294

293295
@property
294-
def resultantdata(self) -> list[float]:
296+
def resultantdata(self) -> Optional[list[float]]:
295297
if not self._resultantdata:
296298
if self.forces:
297299
normalcomponents = [f["c_np"] - f["c_nn"] for f in self.forces]

src/compas_dem/notebook/buffers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def mesh_to_facesbuffer(mesh: Mesh, color: Color) -> tuple[list[list[float]], li
134134
colors.append(color)
135135

136136
else:
137-
ears = earclip_polygon(Polygon([mesh.vertex_coordinates(v) for v in vertices]))
137+
ears: list[list[int]] = earclip_polygon(Polygon([mesh.vertex_coordinates(v) for v in vertices])) # type: ignore
138138
for ear in ears:
139139
positions.append(mesh.vertex_coordinates(vertices[ear[0]]))
140140
positions.append(mesh.vertex_coordinates(vertices[ear[1]]))

src/compas_dem/notebook/modelobject.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Optional
2+
from typing import Union
23

34
import pythreejs as three
45
from compas.colors import Color
@@ -40,7 +41,7 @@ def __init__(
4041

4142
@property
4243
def model(self) -> BlockModel:
43-
return self.item
44+
return self.item # type: ignore
4445

4546
@model.setter
4647
def model(self, model: BlockModel) -> None:
@@ -77,7 +78,7 @@ def draw(self):
7778

7879
return self.guids
7980

80-
def draw_blocks(self) -> tuple[three.Mesh, three.LineSegments]:
81+
def draw_blocks(self) -> tuple[Union[three.Mesh, None], three.LineSegments]:
8182
"""Draw the blocks of the model."""
8283
meshes = [block.modelgeometry for block in self.model.blocks()]
8384

0 commit comments

Comments
 (0)