Stop using the dataclass module
This commit is contained in:
parent
6f0555c21b
commit
1faee1b550
2 changed files with 10 additions and 5 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue