From 1faee1b55063b167a5130b36f7669d71c607ddc5 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 22 Jun 2019 22:20:50 +0000 Subject: [PATCH] Stop using the dataclass module --- CHANGELOG.md | 1 + bowl/config.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b222e0..bd472d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Next version - Fix indentation of multi-line messages +- Stop using dataclass (for backwards compatibility with Python 3.6) ## 1.0.0 (2019-06-21) diff --git a/bowl/config.py b/bowl/config.py index a25f599..19fb1ec 100644 --- a/bowl/config.py +++ b/bowl/config.py @@ -1,4 +1,3 @@ -from dataclasses import dataclass, field from enum import Enum, auto from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple @@ -62,12 +61,17 @@ class Kind(Enum): Condition = Callable[[Any], bool] -@dataclass class Option: - kind: Kind - default: Any - conditions: Iterable[Tuple[Condition, str]] = field(default_factory=list) + def __init__(self, + kind: Kind, + default: Any, + conditions: Iterable[Tuple[Condition, str]] = frozenset(), + ) -> None: + + self.kind = kind + self.default = default + self.conditions = conditions def check_valid(self, value: Any) -> None: if not self.kind.matches(value):