diff options
author | jaseg <git@jaseg.de> | 2022-06-21 12:26:38 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-06-21 12:26:38 +0200 |
commit | 218f9d9b1f0c28969a339beead4a059a46f728dc (patch) | |
tree | 20a97044045bc143ff10082b61183495c913b38b /gerbonara/graphic_primitives.py | |
parent | ee233317f1c5541a302c4f062b9957ae7ea335c2 (diff) | |
download | gerbonara-218f9d9b1f0c28969a339beead4a059a46f728dc.tar.gz gerbonara-218f9d9b1f0c28969a339beead4a059a46f728dc.tar.bz2 gerbonara-218f9d9b1f0c28969a339beead4a059a46f728dc.zip |
Make gerbonara python3.8 compatible.v0.11.0
Diffstat (limited to 'gerbonara/graphic_primitives.py')
-rw-r--r-- | gerbonara/graphic_primitives.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gerbonara/graphic_primitives.py b/gerbonara/graphic_primitives.py index dd421a7..072a98a 100644 --- a/gerbonara/graphic_primitives.py +++ b/gerbonara/graphic_primitives.py @@ -19,7 +19,7 @@ import math import itertools -from dataclasses import dataclass, KW_ONLY, replace +from dataclasses import dataclass, replace from .utils import * @@ -28,8 +28,18 @@ prec = lambda x: f'{float(x):.6}' @dataclass class GraphicPrimitive: - _ : KW_ONLY - polarity_dark : bool = True + + # hackety hack: Work around python < 3.10 not having dataclasses.KW_ONLY. + # + # For details, refer to graphic_objects.py + def __init_subclass__(cls): + cls.polarity_dark = True + + d = {'polarity_dark': bool} + if hasattr(cls, '__annotations__'): + cls.__annotations__.update(d) + else: + cls.__annotations__ = d def bounding_box(self): """ Return the axis-aligned bounding box of this feature. |