-
Notifications
You must be signed in to change notification settings - Fork 44
/
integer.py
38 lines (27 loc) · 990 Bytes
/
integer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from typing import List, Tuple
from .base import BaseSchema, TreeNode
from .number import NumberSchema
class IntegerSchema(NumberSchema):
'''Special case of NumberSchema'''
def __init__(self, path: list, schema: dict) -> None:
super().__init__(path, schema)
if self.default == None:
self.default = 0
def get_all_schemas(self) -> Tuple[list, list, list]:
if self.problematic:
return [], [], []
return [self], [], []
def get_normal_semantic_schemas(self) -> Tuple[List['BaseSchema'], List['BaseSchema']]:
if self.problematic:
return [], []
return [self], []
def to_tree(self) -> TreeNode:
return TreeNode(self.path)
def load_examples(self, example: int):
self.examples.append(example)
def set_default(self, instance):
self.default = int(instance)
def empty_value(self):
return 0
def __str__(self) -> str:
return 'Integer'