@@ -78,7 +78,7 @@ def __init__(
7878 self ,
7979 obj : Compound | Face ,
8080 rotation : float = 0 ,
81- align : Align | tuple [Align , Align ] = None ,
81+ align : Align | tuple [Align , Align ] | None = None ,
8282 mode : Mode = Mode .ADD ,
8383 ):
8484 if align is not None :
@@ -123,7 +123,7 @@ class Circle(BaseSketchObject):
123123 def __init__ (
124124 self ,
125125 radius : float ,
126- align : Align | tuple [Align , Align ] = (Align .CENTER , Align .CENTER ),
126+ align : Align | tuple [Align , Align ] | None = (Align .CENTER , Align .CENTER ),
127127 mode : Mode = Mode .ADD ,
128128 ):
129129 context = BuildSketch ._get_context (self )
@@ -157,7 +157,7 @@ def __init__(
157157 x_radius : float ,
158158 y_radius : float ,
159159 rotation : float = 0 ,
160- align : Align | tuple [Align , Align ] = (Align .CENTER , Align .CENTER ),
160+ align : Align | tuple [Align , Align ] | None = (Align .CENTER , Align .CENTER ),
161161 mode : Mode = Mode .ADD ,
162162 ):
163163 context = BuildSketch ._get_context (self )
@@ -196,14 +196,14 @@ def __init__(
196196 self ,
197197 * pts : VectorLike | Iterable [VectorLike ],
198198 rotation : float = 0 ,
199- align : Align | tuple [Align , Align ] = (Align .CENTER , Align .CENTER ),
199+ align : Align | tuple [Align , Align ] | None = (Align .CENTER , Align .CENTER ),
200200 mode : Mode = Mode .ADD ,
201201 ):
202202 context = BuildSketch ._get_context (self )
203203 validate_inputs (context , self )
204204
205- pts = flatten_sequence (* pts )
206- self .pts = pts
205+ flattened_pts = flatten_sequence (* pts )
206+ self .pts = flattened_pts
207207 self .align = tuplify (align , 2 )
208208
209209 poly_pts = [Vector (p ) for p in pts ]
@@ -232,7 +232,7 @@ def __init__(
232232 width : float ,
233233 height : float ,
234234 rotation : float = 0 ,
235- align : Align | tuple [Align , Align ] = (Align .CENTER , Align .CENTER ),
235+ align : Align | tuple [Align , Align ] | None = (Align .CENTER , Align .CENTER ),
236236 mode : Mode = Mode .ADD ,
237237 ):
238238 context = BuildSketch ._get_context (self )
@@ -269,7 +269,7 @@ def __init__(
269269 height : float ,
270270 radius : float ,
271271 rotation : float = 0 ,
272- align : Align | tuple [Align , Align ] = (Align .CENTER , Align .CENTER ),
272+ align : Align | tuple [Align , Align ] | None = (Align .CENTER , Align .CENTER ),
273273 mode : Mode = Mode .ADD ,
274274 ):
275275 context = BuildSketch ._get_context (self )
@@ -354,9 +354,9 @@ def __init__(
354354 maxs = [pts_sorted [0 ][- 1 ].X , pts_sorted [1 ][- 1 ].Y ]
355355
356356 align_offset = to_align_offset (mins , maxs , align , center = (0 , 0 ))
357- pts = [point + align_offset for point in pts ]
357+ pts_ao = [point + align_offset for point in pts ]
358358
359- face = Face (Wire .make_polygon (pts ))
359+ face = Face (Wire .make_polygon (pts_ao ))
360360 super ().__init__ (face , rotation = 0 , align = None , mode = mode )
361361
362362
@@ -510,7 +510,7 @@ def __init__(
510510 width : float ,
511511 height : float ,
512512 rotation : float = 0 ,
513- align : Align | tuple [Align , Align ] = (Align .CENTER , Align .CENTER ),
513+ align : Align | tuple [Align , Align ] | None = (Align .CENTER , Align .CENTER ),
514514 mode : Mode = Mode .ADD ,
515515 ):
516516 if width <= height :
@@ -525,7 +525,7 @@ def __init__(
525525 self .slot_height = height
526526
527527 if width != height :
528- face = Face (
528+ face : Face | None = Face (
529529 Wire (
530530 [
531531 Edge .make_line (Vector (- width / 2 + height / 2 , 0 , 0 ), Vector ()),
@@ -566,14 +566,14 @@ def __init__(
566566 txt : str ,
567567 font_size : float ,
568568 font : str = "Arial" ,
569- font_path : str = None ,
569+ font_path : str | None = None ,
570570 font_style : FontStyle = FontStyle .REGULAR ,
571- align : Align | tuple [Align , Align ] = (Align .CENTER , Align .CENTER ),
572- path : Edge | Wire = None ,
571+ align : Align | tuple [Align , Align ] | None = (Align .CENTER , Align .CENTER ),
572+ path : Edge | Wire | None = None ,
573573 position_on_path : float = 0.0 ,
574- rotation : float = 0 ,
574+ rotation : float = 0.0 ,
575575 mode : Mode = Mode .ADD ,
576- ) -> Compound :
576+ ):
577577 context = BuildSketch ._get_context (self )
578578 validate_inputs (context , self )
579579
@@ -594,7 +594,7 @@ def __init__(
594594 font = font ,
595595 font_path = font_path ,
596596 font_style = font_style ,
597- align = tuplify ( align , 2 ) ,
597+ align = align ,
598598 position_on_path = position_on_path ,
599599 text_path = path ,
600600 )
@@ -628,9 +628,9 @@ def __init__(
628628 width : float ,
629629 height : float ,
630630 left_side_angle : float ,
631- right_side_angle : float = None ,
631+ right_side_angle : float | None = None ,
632632 rotation : float = 0 ,
633- align : Align | tuple [Align , Align ] = (Align .CENTER , Align .CENTER ),
633+ align : Align | tuple [Align , Align ] | None = (Align .CENTER , Align .CENTER ),
634634 mode : Mode = Mode .ADD ,
635635 ):
636636 context = BuildSketch ._get_context (self )
@@ -710,13 +710,13 @@ class Triangle(BaseSketchObject):
710710 def __init__ (
711711 self ,
712712 * ,
713- a : float = None ,
714- b : float = None ,
715- c : float = None ,
716- A : float = None ,
717- B : float = None ,
718- C : float = None ,
719- align : None | Align | tuple [Align , Align ] = None ,
713+ a : float | None = None ,
714+ b : float | None = None ,
715+ c : float | None = None ,
716+ A : float | None = None ,
717+ B : float | None = None ,
718+ C : float | None = None ,
719+ align : Align | tuple [Align , Align ] | None = None ,
720720 rotation : float = 0 ,
721721 mode : Mode = Mode .ADD ,
722722 ):
@@ -729,27 +729,29 @@ def __init__(
729729 raise ValueError ("One length and two other values must be provided" )
730730
731731 A , B , C = (radians (angle ) if angle is not None else None for angle in [A , B , C ])
732- a , b , c , A , B , C = trianglesolver .solve (a , b , c , A , B , C )
733- self .a = a #: length of side 'a'
734- self .b = b #: length of side 'b'
735- self .c = c #: length of side 'c'
736- self .A = degrees (A ) #: interior angle 'A' in degrees
737- self .B = degrees (B ) #: interior angle 'B' in degrees
738- self .C = degrees (C ) #: interior angle 'C' in degrees
732+ ar , br , cr , Ar , Br , Cr = trianglesolver .solve (a , b , c , A , B , C )
733+ self .a = ar #: length of side 'a'
734+ self .b = br #: length of side 'b'
735+ self .c = cr #: length of side 'c'
736+ self .A = degrees (Ar ) #: interior angle 'A' in degrees
737+ self .B = degrees (Br ) #: interior angle 'B' in degrees
738+ self .C = degrees (Cr ) #: interior angle 'C' in degrees
739739 triangle = Face (
740740 Wire .make_polygon (
741- [Vector (0 , 0 ), Vector (a , 0 ), Vector (c , 0 ).rotate (Axis .Z , self .B )]
741+ [Vector (0 , 0 ), Vector (ar , 0 ), Vector (cr , 0 ).rotate (Axis .Z , self .B )]
742742 )
743743 )
744- center_of_geometry = sum (Vector (v ) for v in triangle .vertices ()) / 3
744+ center_of_geometry = (
745+ sum ((Vector (v ) for v in triangle .vertices ()), Vector (0 , 0 , 0 )) / 3
746+ )
745747 triangle .move (Location (- center_of_geometry ))
746748 alignment = None if align is None else tuplify (align , 2 )
747749 super ().__init__ (obj = triangle , rotation = rotation , align = alignment , mode = mode )
748- self .edge_a = self .edges ().filter_by (lambda e : abs (e .length - a ) < TOLERANCE )[
750+ self .edge_a = self .edges ().filter_by (lambda e : abs (e .length - ar ) < TOLERANCE )[
749751 0
750752 ] #: edge 'a'
751753 self .edge_b = self .edges ().filter_by (
752- lambda e : abs (e .length - b ) < TOLERANCE and e not in [self .edge_a ]
754+ lambda e : abs (e .length - br ) < TOLERANCE and e not in [self .edge_a ]
753755 )[
754756 0
755757 ] #: edge 'b'
0 commit comments