-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathtyping.py
More file actions
62 lines (48 loc) · 2.19 KB
/
typing.py
File metadata and controls
62 lines (48 loc) · 2.19 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
typing.py
Copyright (c) 2013-2021 Snowplow Analytics Ltd. All rights reserved.
This program is licensed to you under the Apache License Version 2.0,
and you may not use this file except in compliance with the Apache License
Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing,
software distributed under the Apache License Version 2.0 is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the Apache License Version 2.0 for the specific
language governing permissions and limitations there under.
Authors: Anuj More, Alex Dean, Fred Blundun, Paul Boocock, Matus Tomlein
Copyright: Copyright (c) 2013-2021 Snowplow Analytics Ltd
License: Apache License Version 2.0
"""
from typing import Dict, List, Callable, Any, Optional, Union, Tuple
from typing_extensions import Protocol, Literal
PayloadDict = Dict[str, Any]
PayloadDictList = List[PayloadDict]
JsonEncoderFunction = Callable[[Any], Any]
# tracker
FORM_NODE_NAMES = {"INPUT", "TEXTAREA", "SELECT"}
FORM_TYPES = {
"button", "checkbox", "color", "date", "datetime",
"datetime-local", "email", "file", "hidden", "image", "month",
"number", "password", "radio", "range", "reset", "search",
"submit", "tel", "text", "time", "url", "week"
}
FormNodeName = Literal["INPUT", "TEXTAREA", "SELECT"]
ElementClasses = Union[List[str], Tuple[str, Any]]
FormClasses = Union[List[str], Tuple[str, Any]]
# emitters
HttpProtocol = Literal["http", "https"]
Method = Literal["get", "post"]
SuccessCallback = Callable[[PayloadDictList], None]
FailureCallback = Callable[[int, PayloadDictList], None]
# subject
SUPPORTED_PLATFORMS = {"pc", "tv", "mob", "cnsl", "iot", "web", "srv", "app"}
SupportedPlatform = Literal["pc", "tv", "mob", "cnsl", "iot", "web", "srv", "app"]
class EmitterProtocol(Protocol):
def input(self, payload: PayloadDict) -> None:
...
class RedisProtocol(Protocol):
def rpush(self, name: Any, *values: Any) -> int:
...
def lpop(self, name: Any, count: Optional[int] = ...) -> Any:
...