summaryrefslogtreecommitdiff
path: root/gerbonara/graphic_objects.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-06-21 12:26:38 +0200
committerjaseg <git@jaseg.de>2022-06-21 12:26:38 +0200
commit218f9d9b1f0c28969a339beead4a059a46f728dc (patch)
tree20a97044045bc143ff10082b61183495c913b38b /gerbonara/graphic_objects.py
parentee233317f1c5541a302c4f062b9957ae7ea335c2 (diff)
downloadgerbonara-218f9d9b1f0c28969a339beead4a059a46f728dc.tar.gz
gerbonara-218f9d9b1f0c28969a339beead4a059a46f728dc.tar.bz2
gerbonara-218f9d9b1f0c28969a339beead4a059a46f728dc.zip
Make gerbonara python3.8 compatible.v0.11.0
Diffstat (limited to 'gerbonara/graphic_objects.py')
-rw-r--r--gerbonara/graphic_objects.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/gerbonara/graphic_objects.py b/gerbonara/graphic_objects.py
index 3136b39..35c08f3 100644
--- a/gerbonara/graphic_objects.py
+++ b/gerbonara/graphic_objects.py
@@ -18,7 +18,7 @@
import math
import copy
-from dataclasses import dataclass, KW_ONLY, astuple, replace, field, fields
+from dataclasses import dataclass, astuple, replace, field, fields
from .utils import MM, InterpMode, to_unit, rotate_point
from . import graphic_primitives as gp
@@ -45,6 +45,8 @@ class GraphicObject:
# hackety hack: Work around python < 3.10 not having dataclasses.KW_ONLY. Once we drop python 3.8 and 3.9, we can
# get rid of this, just set these as normal fields, and decorate GraphicObject with @dataclass.
+ #
+ # See also: apertures.py, graphic_primitives.py
def __init_subclass__(cls):
#: bool representing the *color* of this feature: whether this is a *dark* or *clear* feature. Clear and dark are
#: meant in the sense that they are used in the Gerber spec and refer to whether the transparency film that this
@@ -61,7 +63,11 @@ class GraphicObject:
#: which are stored in the :py:class:`.GerberFile` object instead.
cls.attrs = field(default_factory=dict)
- cls.__annotations__.update({'polarity_dark' : bool, 'unit' : str, 'attrs': dict})
+ d = {'polarity_dark' : bool, 'unit' : str, 'attrs': dict}
+ if hasattr(cls, '__annotations__'):
+ cls.__annotations__.update(d)
+ else:
+ cls.__annotations__ = d
def converted(self, unit):