From 218f9d9b1f0c28969a339beead4a059a46f728dc Mon Sep 17 00:00:00 2001 From: jaseg Date: Tue, 21 Jun 2022 12:26:38 +0200 Subject: Make gerbonara python3.8 compatible. --- gerbonara/graphic_primitives.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'gerbonara/graphic_primitives.py') 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. -- cgit