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
|
## Next version
|
||||||
|
|
||||||
- Fix indentation of multi-line messages
|
- Fix indentation of multi-line messages
|
||||||
|
- Stop using dataclass (for backwards compatibility with Python 3.6)
|
||||||
|
|
||||||
## 1.0.0 (2019-06-21)
|
## 1.0.0 (2019-06-21)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
from dataclasses import dataclass, field
|
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple
|
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple
|
||||||
|
|
||||||
|
|
@ -62,12 +61,17 @@ class Kind(Enum):
|
||||||
|
|
||||||
Condition = Callable[[Any], bool]
|
Condition = Callable[[Any], bool]
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class Option:
|
class Option:
|
||||||
|
|
||||||
kind: Kind
|
def __init__(self,
|
||||||
default: Any
|
kind: Kind,
|
||||||
conditions: Iterable[Tuple[Condition, str]] = field(default_factory=list)
|
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:
|
def check_valid(self, value: Any) -> None:
|
||||||
if not self.kind.matches(value):
|
if not self.kind.matches(value):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue