summaryrefslogtreecommitdiff
path: root/lib/elements/element.py
diff options
context:
space:
mode:
authorcapellancitizen <thecapellancitizen@gmail.com>2025-03-09 21:21:48 -0400
committerGitHub <noreply@github.com>2025-03-09 21:21:48 -0400
commit99509df8d8abf1e7b701a4a09cf170a362f6d878 (patch)
treea461549502fa9f37dc287789b6c7db81dfcd5368 /lib/elements/element.py
parent0d2fc24f25f87562f0755b53dad6204efad1330d (diff)
Mypy type correctness (#3199)
Diffstat (limited to 'lib/elements/element.py')
-rw-r--r--lib/elements/element.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/elements/element.py b/lib/elements/element.py
index ea2d5d6b..6f2c52e9 100644
--- a/lib/elements/element.py
+++ b/lib/elements/element.py
@@ -2,6 +2,7 @@
#
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
+from __future__ import annotations
import json
import sys
from contextlib import contextmanager
@@ -79,8 +80,9 @@ class EmbroideryElement(object):
prop = getattr(cls, attr)
if isinstance(prop, property):
# The 'param' attribute is set by the 'param' decorator defined above.
- if hasattr(prop.fget, 'param'):
- params.append(prop.fget.param)
+ fget = prop.fget
+ if fget is not None and hasattr(fget, 'param'):
+ params.append(fget.param)
return params
@cache
@@ -215,18 +217,18 @@ class EmbroideryElement(object):
# First, figure out the translation component of the transform. Using a zero
# vector completely cancels out the rotation, scale, and skew components.
- zero = [0, 0]
+ zero = (0, 0)
zero = inkex.Transform.apply_to_point(node_transform, zero)
translate = Point(*zero)
# Next, see how the transform affects unit vectors in the X and Y axes. We
# need to subtract off the translation or it will affect the magnitude of
# the resulting vector, which we don't want.
- unit_x = [1, 0]
+ unit_x = (1, 0)
unit_x = inkex.Transform.apply_to_point(node_transform, unit_x)
sx = (Point(*unit_x) - translate).length()
- unit_y = [0, 1]
+ unit_y = (0, 1)
unit_y = inkex.Transform.apply_to_point(node_transform, unit_y)
sy = (Point(*unit_y) - translate).length()
@@ -455,7 +457,7 @@ class EmbroideryElement(object):
raise NotImplementedError("INTERNAL ERROR: %s must implement shape()", self.__class__)
@property
- def first_stitch(self):
+ def first_stitch(self) -> Optional[ShapelyPoint]:
# first stitch is an approximation to where the first stitch may possibly be
# if not defined through commands or repositioned by the previous element
raise NotImplementedError("INTERNAL ERROR: %s must implement first_stitch()", self.__class__)
@@ -521,7 +523,7 @@ class EmbroideryElement(object):
return lock_start, lock_end
- def to_stitch_groups(self, last_stitch_group: Optional[StitchGroup], next_element: Optional[ShapelyPoint] = None) -> List[StitchGroup]:
+ def to_stitch_groups(self, last_stitch_group: Optional[StitchGroup], next_element: Optional[EmbroideryElement] = None) -> List[StitchGroup]:
raise NotImplementedError("%s must implement to_stitch_groups()" % self.__class__.__name__)
@debug.time