[shapes] Don't create empty dicts for annotations

This commit is contained in:
Jan Petykiewicz 2025-04-24 23:19:40 -07:00
parent 5368fd4e16
commit 037118883b
6 changed files with 18 additions and 18 deletions

View File

@ -157,7 +157,7 @@ class Arc(Shape):
offset: ArrayLike = (0.0, 0.0),
rotation: float = 0,
repetition: Repetition | None = None,
annotations: annotations_t | None = None,
annotations: annotations_t = None,
raw: bool = False,
) -> None:
if raw:
@ -170,7 +170,7 @@ class Arc(Shape):
self._offset = offset
self._rotation = rotation
self._repetition = repetition
self._annotations = annotations if annotations is not None else {}
self._annotations = annotations
else:
self.radii = radii
self.angles = angles
@ -178,7 +178,7 @@ class Arc(Shape):
self.offset = offset
self.rotation = rotation
self.repetition = repetition
self.annotations = annotations if annotations is not None else {}
self.annotations = annotations
def __deepcopy__(self, memo: dict | None = None) -> 'Arc':
memo = {} if memo is None else memo

View File

@ -48,7 +48,7 @@ class Circle(Shape):
*,
offset: ArrayLike = (0.0, 0.0),
repetition: Repetition | None = None,
annotations: annotations_t | None = None,
annotations: annotations_t = None,
raw: bool = False,
) -> None:
if raw:
@ -56,12 +56,12 @@ class Circle(Shape):
self._radius = radius
self._offset = offset
self._repetition = repetition
self._annotations = annotations if annotations is not None else {}
self._annotations = annotations
else:
self.radius = radius
self.offset = offset
self.repetition = repetition
self.annotations = annotations if annotations is not None else {}
self.annotations = annotations
def __deepcopy__(self, memo: dict | None = None) -> 'Circle':
memo = {} if memo is None else memo

View File

@ -93,7 +93,7 @@ class Ellipse(Shape):
offset: ArrayLike = (0.0, 0.0),
rotation: float = 0,
repetition: Repetition | None = None,
annotations: annotations_t | None = None,
annotations: annotations_t = None,
raw: bool = False,
) -> None:
if raw:
@ -103,13 +103,13 @@ class Ellipse(Shape):
self._offset = offset
self._rotation = rotation
self._repetition = repetition
self._annotations = annotations if annotations is not None else {}
self._annotations = annotations
else:
self.radii = radii
self.offset = offset
self.rotation = rotation
self.repetition = repetition
self.annotations = annotations if annotations is not None else {}
self.annotations = annotations
def __deepcopy__(self, memo: dict | None = None) -> Self:
memo = {} if memo is None else memo

View File

@ -170,7 +170,7 @@ class Path(Shape):
offset: ArrayLike = (0.0, 0.0),
rotation: float = 0,
repetition: Repetition | None = None,
annotations: annotations_t | None = None,
annotations: annotations_t = None,
raw: bool = False,
) -> None:
self._cap_extensions = None # Since .cap setter might access it
@ -182,7 +182,7 @@ class Path(Shape):
self._vertices = vertices
self._offset = offset
self._repetition = repetition
self._annotations = annotations if annotations is not None else {}
self._annotations = annotations
self._width = width
self._cap = cap
self._cap_extensions = cap_extensions
@ -190,7 +190,7 @@ class Path(Shape):
self.vertices = vertices
self.offset = offset
self.repetition = repetition
self.annotations = annotations if annotations is not None else {}
self.annotations = annotations
self.width = width
self.cap = cap
self.cap_extensions = cap_extensions

View File

@ -92,7 +92,7 @@ class Polygon(Shape):
offset: ArrayLike = (0.0, 0.0),
rotation: float = 0.0,
repetition: Repetition | None = None,
annotations: annotations_t | None = None,
annotations: annotations_t = None,
raw: bool = False,
) -> None:
if raw:
@ -101,12 +101,12 @@ class Polygon(Shape):
self._vertices = vertices
self._offset = offset
self._repetition = repetition
self._annotations = annotations if annotations is not None else {}
self._annotations = annotations
else:
self.vertices = vertices
self.offset = offset
self.repetition = repetition
self.annotations = annotations if annotations is not None else {}
self.annotations = annotations
if rotation:
self.rotate(rotation)

View File

@ -71,7 +71,7 @@ class Text(RotatableImpl, Shape):
offset: ArrayLike = (0.0, 0.0),
rotation: float = 0.0,
repetition: Repetition | None = None,
annotations: annotations_t | None = None,
annotations: annotations_t = None,
raw: bool = False,
) -> None:
if raw:
@ -81,14 +81,14 @@ class Text(RotatableImpl, Shape):
self._height = height
self._rotation = rotation
self._repetition = repetition
self._annotations = annotations if annotations is not None else {}
self._annotations = annotations
else:
self.offset = offset
self.string = string
self.height = height
self.rotation = rotation
self.repetition = repetition
self.annotations = annotations if annotations is not None else {}
self.annotations = annotations
self.font_path = font_path
def __deepcopy__(self, memo: dict | None = None) -> Self: