Skip to content

Commit b5e372b

Browse files
rowilliagvanrossum
authored andcommitted
Add stubs for itsdangerous. (#537)
This is needed for #28
1 parent 773ad48 commit b5e372b

File tree

2 files changed

+309
-0
lines changed

2 files changed

+309
-0
lines changed

third_party/2.7/itsdangerous.pyi

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Stubs for itsdangerous (Python 2.7)
2+
#
3+
# NOTE: This dynamically typed stub was automatically generated by stubgen.
4+
5+
from datetime import datetime
6+
from itertools import izip
7+
from typing import Any, Callable, IO, MutableMapping, Optional, Text, Tuple, Union
8+
9+
PY2 = ... # type: bool
10+
text_type = unicode
11+
int_to_byte = chr
12+
number_types = (int, long, float)
13+
14+
bytes_like = Union[bytearray, str]
15+
16+
class _CompactJSON:
17+
def loads(self, payload: Text) -> Any: ...
18+
def dumps(self, obj: Any) -> Text: ...
19+
20+
compact_json = _CompactJSON
21+
EPOCH = ... # type: int
22+
23+
def want_bytes(s: str, encoding='', errors='') -> str: ...
24+
def is_text_serializer(serializer: Any) -> bool: ...
25+
def constant_time_compare(val1: bytes_like, val2: bytes_like) -> bool: ...
26+
27+
class BadData(Exception):
28+
message = ... # type: str
29+
def __init__(self, message: str) -> None: ...
30+
31+
class BadPayload(BadData):
32+
original_error = ... # type: Optional[Exception]
33+
def __init__(self, message: str, original_error: Optional[Exception]=None) -> None: ...
34+
35+
class BadSignature(BadData):
36+
payload = ... # type: Optional[Any]
37+
def __init__(self, message: str, payload: Optional[Any]=None) -> None: ...
38+
39+
class BadTimeSignature(BadSignature):
40+
date_signed = ... # type: Optional[int]
41+
def __init__(self, message, payload: Optional[Any]=None, date_signed: Optional[int]=None) -> None: ...
42+
43+
class BadHeader(BadSignature):
44+
header = ... # type: Any
45+
original_error = ... # type: Any
46+
def __init__(self, message, payload=None, header=None, original_error=None) -> None: ...
47+
48+
class SignatureExpired(BadTimeSignature): ...
49+
50+
def base64_encode(string: bytes_like) -> str: ...
51+
def base64_decode(string: bytes_like) -> str: ...
52+
def int_to_bytes(num: int) -> str: ...
53+
def bytes_to_int(bytestr: bytes_like) -> int: ...
54+
55+
class SigningAlgorithm:
56+
def get_signature(self, key: bytes_like, value: bytes_like) -> str: ...
57+
def verify_signature(self, key: bytes_like, value: bytes_like, sig: bytes_like) -> bool: ...
58+
59+
class NoneAlgorithm(SigningAlgorithm):
60+
def get_signature(self, key: bytes_like, value: bytes_like) -> str: ...
61+
62+
class HMACAlgorithm(SigningAlgorithm):
63+
default_digest_method = ... # type: Callable
64+
digest_method = ... # type: Callable
65+
def __init__(self, digest_method: Optional[Callable]=None) -> None: ...
66+
def get_signature(self, key: bytes_like, value: bytes_like) -> str: ...
67+
68+
class Signer:
69+
default_digest_method = ... # type: Callable
70+
default_key_derivation = ... # type: str
71+
secret_key = ... # type: bytes_like
72+
sep = ... # type: str
73+
salt = ... # type: bytes_like
74+
key_derivation = ... # type: str
75+
digest_method = ... # type: Callable
76+
algorithm = ... # type: SigningAlgorithm
77+
def __init__(self, secret_key: bytes_like, salt: Optional[bytes_like]=None, sep: Optional[str]='',
78+
key_derivation: Optional[str]=None,
79+
digest_method: Optional[Callable]=None,
80+
algorithm: Optional[SigningAlgorithm]=None) -> None: ...
81+
def derive_key(self) -> str: ...
82+
def get_signature(self, value: bytes_like) -> str: ...
83+
def sign(self, value: bytes_like) -> str: ...
84+
def verify_signature(self, value: bytes_like, sig: bytes_like) -> bool: ...
85+
def unsign(self, signed_value: str) -> str: ...
86+
def validate(self, signed_value: str) -> bool: ...
87+
88+
class TimestampSigner(Signer):
89+
def get_timestamp(self) -> int: ...
90+
def timestamp_to_datetime(self, ts: int) -> datetime: ...
91+
def sign(self, value: bytes_like) -> str: ...
92+
def unsign(self, value: str, max_age: Optional[int]=None, return_timestamp=False) -> Any: ...
93+
def validate(self, signed_value: str, max_age: Optional[int]=None) -> bool: ...
94+
95+
class Serializer:
96+
default_serializer = ... # type: Any
97+
default_signer = ... # type: Callable[..., Signer]
98+
secret_key = ... # type: Any
99+
salt = ... # type: bytes_like
100+
serializer = ... # type: Any
101+
is_text_serializer = ... # type: bool
102+
signer = ... # type: Signer
103+
signer_kwargs = ... # type: MutableMapping
104+
def __init__(self, secret_key: bytes_like, salt: Optional[bytes_like]=b'', serializer=None, signer: Optional[Callable[..., Signer]]=None, signer_kwargs: Optional[MutableMapping]=None) -> None: ...
105+
def load_payload(self, payload: Any, serializer=None) -> Any: ...
106+
def dump_payload(self, *args, **kwargs) -> str: ...
107+
def make_signer(self, salt: Optional[bytes_like]=None) -> Signer: ...
108+
def dumps(self, obj: Any, salt: Optional[bytes_like]=None) -> str: ...
109+
def dump(self, obj: Any, f: IO[str], salt: Optional[bytes_like]=None) -> None: ...
110+
def loads(self, s: str, salt: Optional[bytes_like]=None) -> Any: ...
111+
def load(self, f: IO[str], salt: Optional[bytes_like]=None): ...
112+
def loads_unsafe(self, s, salt: Optional[bytes_like]=None) -> Tuple[bool, Any]: ...
113+
def load_unsafe(self, f: IO[str], *args, **kwargs) -> Tuple[bool, Any]: ...
114+
115+
class TimedSerializer(Serializer):
116+
default_signer = ... # type: Callable[..., TimestampSigner]
117+
def loads(self, s: str, salt: Optional[bytes_like]=None, max_age: Optional[int]=None, return_timestamp=False) -> Any: ...
118+
def loads_unsafe(self, s: str, salt: Optional[bytes_like]=None, max_age: Optional[int]=None) -> Tuple[bool, Any]: ...
119+
120+
class JSONWebSignatureSerializer(Serializer):
121+
jws_algorithms = ... # type: MutableMapping[str, SigningAlgorithm]
122+
default_algorithm = ... # type: str
123+
default_serializer = ... # type: Any
124+
algorithm_name = ... # type: str
125+
algorithm = ... # type: Any
126+
def __init__(self, secret_key: bytes_like, salt: Optional[bytes_like]=None, serializer=None, signer: Optional[Callable[..., Signer]]=None, signer_kwargs: Optional[MutableMapping]=None, algorithm_name: Optional[str]=None) -> None: ...
127+
def load_payload(self, payload: Any, return_header=False) -> Any: ...
128+
def dump_payload(self, *args, **kwargs) -> str: ...
129+
def make_algorithm(self, algorithm_name: str) -> SigningAlgorithm: ...
130+
def make_signer(self, salt: Optional[bytes_like]=None, algorithm_name: Optional[str]=None) -> Signer: ...
131+
def make_header(self, header_fields=Optional[MutableMapping]) -> MutableMapping: ...
132+
def dumps(self, obj: Any, salt: Optional[bytes_like]=None, header_fields=Optional[MutableMapping]) -> str: ...
133+
def loads(self, s: str, salt: Optional[bytes_like]=None, return_header=False) -> Any: ...
134+
def loads_unsafe(self, s, salt: Optional[bytes_like]=None, return_header=False) -> Tuple[bool, Any]: ...
135+
136+
class TimedJSONWebSignatureSerializer(JSONWebSignatureSerializer):
137+
DEFAULT_EXPIRES_IN = ... # type: int
138+
expires_in = ... # type: int
139+
def __init__(self, secret_key: bytes_like, expires_in: Optional[int]=None, **kwargs) -> None: ...
140+
def make_header(self, header_fields=Optional[MutableMapping]) -> MutableMapping: ...
141+
def loads(self, s: str, salt: Optional[bytes_like]=None, return_header=False) -> Any: ...
142+
def get_issue_date(self, header: MutableMapping) -> Optional[datetime]: ...
143+
def now(self) -> int: ...
144+
145+
class URLSafeSerializerMixin:
146+
def load_payload(self, payload: Any, **kwargs) -> Any: ...
147+
def dump_payload(self, *args, **kwargs) -> str: ...
148+
149+
class URLSafeSerializer(URLSafeSerializerMixin, Serializer):
150+
default_serializer = ... # type: Any
151+
152+
class URLSafeTimedSerializer(URLSafeSerializerMixin, TimedSerializer):
153+
default_serializer = ... # type: Any

third_party/3/itsdangerous.pyi

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Stubs for itsdangerous (Python 3)
2+
#
3+
# NOTE: This dynamically typed stub was automatically generated by stubgen.
4+
5+
from datetime import datetime
6+
from typing import Any, Callable, IO, MutableMapping, Optional, Text, Tuple, TypeVar, Union
7+
8+
PY2 = ... # type: bool
9+
text_type = str
10+
int_to_byte = Callable[[int], bytes]
11+
number_types = (int, float)
12+
izip = zip
13+
14+
bytes_like = Union[bytearray, bytes]
15+
str_like = Union[str, bytes]
16+
can_become_bytes = Union[str, bytes, bytearray]
17+
comparable_bytes = TypeVar('comparable_bytes', str, Union[bytes, bytearray])
18+
19+
class _CompactJSON:
20+
def loads(self, payload: Text) -> Any: ...
21+
def dumps(self, obj: Any) -> Text: ...
22+
23+
compact_json = _CompactJSON
24+
EPOCH = ... # type: int
25+
26+
def want_bytes(s: can_become_bytes, encoding='', errors='') -> bytes: ...
27+
def is_text_serializer(serializer: Any) -> bool: ...
28+
def constant_time_compare(val1: comparable_bytes, val2: comparable_bytes) -> bool: ...
29+
30+
class BadData(Exception):
31+
message = ... # type: str
32+
def __init__(self, message: str) -> None: ...
33+
34+
class BadPayload(BadData):
35+
original_error = ... # type: Optional[Exception]
36+
def __init__(self, message: str, original_error: Optional[Exception]=None) -> None: ...
37+
38+
class BadSignature(BadData):
39+
payload = ... # type: Optional[Any]
40+
def __init__(self, message: str, payload: Optional[Any]=None) -> None: ...
41+
42+
class BadTimeSignature(BadSignature):
43+
date_signed = ... # type: Optional[int]
44+
def __init__(self, message, payload: Optional[Any]=None, date_signed: Optional[int]=None) -> None: ...
45+
46+
class BadHeader(BadSignature):
47+
header = ... # type: Any
48+
original_error = ... # type: Any
49+
def __init__(self, message, payload=None, header=None, original_error=None) -> None: ...
50+
51+
class SignatureExpired(BadTimeSignature): ...
52+
53+
def base64_encode(string: can_become_bytes) -> bytes: ...
54+
def base64_decode(string: can_become_bytes) -> bytes: ...
55+
def int_to_bytes(num: int) -> bytes: ...
56+
def bytes_to_int(bytestr: can_become_bytes) -> bytes: ...
57+
58+
class SigningAlgorithm:
59+
def get_signature(self, key: bytes_like, value: bytes_like) -> bytes: ...
60+
def verify_signature(self, key: bytes_like, value: bytes_like, sig: can_become_bytes) -> bool: ...
61+
62+
class NoneAlgorithm(SigningAlgorithm):
63+
def get_signature(self, key: bytes_like, value: bytes_like) -> bytes: ...
64+
65+
class HMACAlgorithm(SigningAlgorithm):
66+
default_digest_method = ... # type: Callable
67+
digest_method = ... # type: Callable
68+
def __init__(self, digest_method: Optional[Callable]=None) -> None: ...
69+
def get_signature(self, key: bytes_like, value: bytes_like) -> bytes: ...
70+
71+
class Signer:
72+
default_digest_method = ... # type: Callable
73+
default_key_derivation = ... # type: str
74+
secret_key = ... # type: can_become_bytes
75+
sep = ... # type: can_become_bytes
76+
salt = ... # type: can_become_bytes
77+
key_derivation = ... # type: str
78+
digest_method = ... # type: Callable
79+
algorithm = ... # type: SigningAlgorithm
80+
def __init__(self, secret_key: can_become_bytes, salt: Optional[can_become_bytes]=None, sep: Optional[can_become_bytes]='',
81+
key_derivation: Optional[str]=None,
82+
digest_method: Optional[Callable]=None,
83+
algorithm: Optional[SigningAlgorithm]=None) -> None: ...
84+
def derive_key(self) -> bytes: ...
85+
def get_signature(self, value: bytes_like) -> bytes: ...
86+
def sign(self, value: bytes_like) -> bytes: ...
87+
def verify_signature(self, value: bytes_like, sig: can_become_bytes) -> bool: ...
88+
def unsign(self, signed_value: can_become_bytes) -> str: ...
89+
def validate(self, signed_value: can_become_bytes) -> bool: ...
90+
91+
class TimestampSigner(Signer):
92+
def get_timestamp(self) -> int: ...
93+
def timestamp_to_datetime(self, ts: int) -> datetime: ...
94+
def sign(self, value: bytes_like) -> bytes: ...
95+
def unsign(self, value: can_become_bytes, max_age: Optional[int]=None, return_timestamp=False) -> Any: ...
96+
def validate(self, signed_value: can_become_bytes, max_age: Optional[int]=None) -> bool: ...
97+
98+
class Serializer:
99+
default_serializer = ... # type: Any
100+
default_signer = ... # type: Callable[..., Signer]
101+
secret_key = ... # type: Any
102+
salt = ... # type: can_become_bytes
103+
serializer = ... # type: Any
104+
is_text_serializer = ... # type: bool
105+
signer = ... # type: Signer
106+
signer_kwargs = ... # type: MutableMapping
107+
def __init__(self, secret_key: can_become_bytes, salt: Optional[can_become_bytes]=b'', serializer=None, signer: Optional[Callable[..., Signer]]=None, signer_kwargs: Optional[MutableMapping]=None) -> None: ...
108+
def load_payload(self, payload: Any, serializer=None) -> Any: ...
109+
def dump_payload(self, *args, **kwargs) -> bytes: ...
110+
def make_signer(self, salt: Optional[can_become_bytes]=None) -> Signer: ...
111+
def dumps(self, obj: Any, salt: Optional[can_become_bytes]=None) -> str_like: ...
112+
def dump(self, obj: Any, f: IO, salt: Optional[can_become_bytes]=None) -> None: ...
113+
def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None) -> Any: ...
114+
def load(self, f: IO, salt: Optional[can_become_bytes]=None): ...
115+
def loads_unsafe(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None) -> Tuple[bool, Any]: ...
116+
def load_unsafe(self, f: IO, *args, **kwargs) -> Tuple[bool, Any]: ...
117+
118+
class TimedSerializer(Serializer):
119+
default_signer = ... # type: Callable[..., TimestampSigner]
120+
def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, max_age: Optional[int]=None, return_timestamp=False) -> Any: ...
121+
def loads_unsafe(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, max_age: Optional[int]=None) -> Tuple[bool, Any]: ...
122+
123+
class JSONWebSignatureSerializer(Serializer):
124+
jws_algorithms = ... # type: MutableMapping[str, SigningAlgorithm]
125+
default_algorithm = ... # type: str
126+
default_serializer = ... # type: Any
127+
algorithm_name = ... # type: str
128+
algorithm = ... # type: Any
129+
def __init__(self, secret_key: can_become_bytes, salt: Optional[can_become_bytes]=None, serializer=None, signer: Optional[Callable[..., Signer]]=None, signer_kwargs: Optional[MutableMapping]=None, algorithm_name: Optional[str]=None) -> None: ...
130+
def load_payload(self, payload: Any, return_header=False) -> Any: ...
131+
def dump_payload(self, *args, **kwargs) -> bytes: ...
132+
def make_algorithm(self, algorithm_name: str) -> SigningAlgorithm: ...
133+
def make_signer(self, salt: Optional[can_become_bytes]=None, algorithm_name: Optional[str]=None) -> Signer: ...
134+
def make_header(self, header_fields=Optional[MutableMapping]) -> MutableMapping: ...
135+
def dumps(self, obj: Any, salt: Optional[can_become_bytes]=None, header_fields=Optional[MutableMapping]) -> str: ...
136+
def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, return_header=False) -> Any: ...
137+
def loads_unsafe(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, return_header=False) -> Tuple[bool, Any]: ...
138+
139+
class TimedJSONWebSignatureSerializer(JSONWebSignatureSerializer):
140+
DEFAULT_EXPIRES_IN = ... # type: int
141+
expires_in = ... # type: int
142+
def __init__(self, secret_key: can_become_bytes, expires_in: Optional[int]=None, **kwargs) -> None: ...
143+
def make_header(self, header_fields=Optional[MutableMapping]) -> MutableMapping: ...
144+
def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, return_header=False) -> Any: ...
145+
def get_issue_date(self, header: MutableMapping) -> Optional[datetime]: ...
146+
def now(self) -> int: ...
147+
148+
class URLSafeSerializerMixin:
149+
def load_payload(self, payload: Any, **kwargs) -> Any: ...
150+
def dump_payload(self, *args, **kwargs) -> bytes: ...
151+
152+
class URLSafeSerializer(URLSafeSerializerMixin, Serializer):
153+
default_serializer = ... # type: Any
154+
155+
class URLSafeTimedSerializer(URLSafeSerializerMixin, TimedSerializer):
156+
default_serializer = ... # type: Any

0 commit comments

Comments
 (0)