Skip to content

Commit 6416707

Browse files
Fix pyright errors
1 parent d502566 commit 6416707

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/sectionproperties/pre/geometry.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -428,13 +428,17 @@ def create_facets_and_control_points(self) -> None:
428428
)
429429

430430
if not self.assigned_control_point:
431-
self.control_points = list(self.geom.representative_point().coords)
431+
repr_point = self.geom.representative_point()
432+
self.control_points = [(repr_point.x, repr_point.y)]
432433
else:
433-
self.control_points = list(self.assigned_control_point.coords)
434+
self.control_points = [
435+
(self.assigned_control_point.x, self.assigned_control_point.y)
436+
]
434437

435438
for hole in self.geom.interiors:
436439
hole_polygon = Polygon(hole)
437-
self.holes += tuple(hole_polygon.representative_point().coords)
440+
hole_repr_point = hole_polygon.representative_point()
441+
self.holes.append((hole_repr_point.x, hole_repr_point.y))
438442

439443
def compile_geometry(self) -> None:
440444
"""Alias for ``create_facets_and_control_points()``.
@@ -697,9 +701,10 @@ def shift_section(
697701
new_ctrl_point: tuple[float, float] | None = None
698702

699703
if self.assigned_control_point:
700-
new_ctrl_point = affinity.translate(
704+
new_ctrl_point_geom = affinity.translate(
701705
self.assigned_control_point, x_offset, y_offset
702-
).coords[0]
706+
)
707+
new_ctrl_point = new_ctrl_point_geom.x, new_ctrl_point_geom.y
703708

704709
return Geometry(
705710
geom=affinity.translate(self.geom, x_offset, y_offset),
@@ -751,12 +756,13 @@ def rotate_section(
751756
else:
752757
rotate_point = rot_point
753758

754-
new_ctrl_point = affinity.rotate(
759+
new_ctrl_point_geom = affinity.rotate(
755760
self.assigned_control_point,
756761
angle,
757762
rotate_point, # pyright: ignore [reportArgumentType]
758763
use_radians,
759-
).coords[0]
764+
)
765+
new_ctrl_point = new_ctrl_point_geom.x, new_ctrl_point_geom.y
760766

761767
return Geometry(
762768
geom=affinity.rotate(self.geom, angle, rot_point, use_radians), # pyright: ignore [reportArgumentType]
@@ -821,13 +827,14 @@ def mirror_section(
821827
new_ctrl_point: tuple[float, float] | None = None
822828

823829
if self.assigned_control_point:
824-
new_ctrl_point = affinity.scale(
830+
new_ctrl_point_geom = affinity.scale(
825831
self.assigned_control_point,
826832
xfact=y_mirror,
827833
yfact=x_mirror,
828834
zfact=1.0,
829835
origin=mirror_point, # pyright: ignore [reportArgumentType]
830-
).coords[0]
836+
)
837+
new_ctrl_point = (new_ctrl_point_geom.x, new_ctrl_point_geom.y)
831838

832839
return Geometry(
833840
geom=mirrored_geom,
@@ -1270,7 +1277,7 @@ def calculate_centroid(self) -> tuple[float, float]:
12701277
Returns:
12711278
Geometry centroid
12721279
"""
1273-
return self.geom.centroid.coords[0]
1280+
return self.geom.centroid.x, self.geom.centroid.y
12741281

12751282
@property
12761283
def recovery_points(self) -> list[tuple[float, float]] | list[Point]:
@@ -2442,8 +2449,7 @@ def compile_geometry(self) -> None:
24422449
for poly in unionized_poly.geoms:
24432450
for interior in poly.interiors:
24442451
rp: Point = Polygon(interior).representative_point()
2445-
coords = rp.coords[0]
2446-
resultant_holes.append(coords)
2452+
resultant_holes.append((rp.x, rp.y))
24472453

24482454
elif isinstance(unionized_poly, Polygon): # pyright: ignore [reportUnnecessaryIsInstance]
24492455
if Geometry(unionized_poly).holes:

0 commit comments

Comments
 (0)