-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add stubs for itsdangerous. #537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
# Stubs for itsdangerous (Python 2.7) | ||
# | ||
# NOTE: This dynamically typed stub was automatically generated by stubgen. | ||
|
||
from datetime import datetime | ||
from itertools import izip | ||
from typing import Any, Callable, IO, MutableMapping, Optional, Text, Tuple, Union | ||
|
||
PY2 = ... # type: bool | ||
text_type = unicode | ||
int_to_byte = chr | ||
number_types = (int, long, float) | ||
|
||
bytes_like = Union[bytearray, str] | ||
|
||
class _CompactJSON: | ||
def loads(self, payload: Text) -> Any: ... | ||
def dumps(self, obj: Any) -> Text: ... | ||
|
||
compact_json = _CompactJSON | ||
EPOCH = ... # type: int | ||
|
||
def want_bytes(s: str, encoding='', errors='') -> str: ... | ||
def is_text_serializer(serializer: Any) -> bool: ... | ||
def constant_time_compare(val1: bytes_like, val2: bytes_like) -> bool: ... | ||
|
||
class BadData(Exception): | ||
message = ... # type: str | ||
def __init__(self, message: str) -> None: ... | ||
|
||
class BadPayload(BadData): | ||
original_error = ... # type: Optional[Exception] | ||
def __init__(self, message: str, original_error: Optional[Exception]=None) -> None: ... | ||
|
||
class BadSignature(BadData): | ||
payload = ... # type: Optional[Any] | ||
def __init__(self, message: str, payload: Optional[Any]=None) -> None: ... | ||
|
||
class BadTimeSignature(BadSignature): | ||
date_signed = ... # type: Optional[int] | ||
def __init__(self, message, payload: Optional[Any]=None, date_signed: Optional[int]=None) -> None: ... | ||
|
||
class BadHeader(BadSignature): | ||
header = ... # type: Any | ||
original_error = ... # type: Any | ||
def __init__(self, message, payload=None, header=None, original_error=None) -> None: ... | ||
|
||
class SignatureExpired(BadTimeSignature): ... | ||
|
||
def base64_encode(string: bytes_like) -> str: ... | ||
def base64_decode(string: bytes_like) -> str: ... | ||
def int_to_bytes(num: int) -> str: ... | ||
def bytes_to_int(bytestr: bytes_like) -> int: ... | ||
|
||
class SigningAlgorithm: | ||
def get_signature(self, key: bytes_like, value: bytes_like) -> str: ... | ||
def verify_signature(self, key: bytes_like, value: bytes_like, sig: bytes_like) -> bool: ... | ||
|
||
class NoneAlgorithm(SigningAlgorithm): | ||
def get_signature(self, key: bytes_like, value: bytes_like) -> str: ... | ||
|
||
class HMACAlgorithm(SigningAlgorithm): | ||
default_digest_method = ... # type: Callable | ||
digest_method = ... # type: Callable | ||
def __init__(self, digest_method: Optional[Callable]=None) -> None: ... | ||
def get_signature(self, key: bytes_like, value: bytes_like) -> str: ... | ||
|
||
class Signer: | ||
default_digest_method = ... # type: Callable | ||
default_key_derivation = ... # type: str | ||
secret_key = ... # type: bytes_like | ||
sep = ... # type: str | ||
salt = ... # type: bytes_like | ||
key_derivation = ... # type: str | ||
digest_method = ... # type: Callable | ||
algorithm = ... # type: SigningAlgorithm | ||
def __init__(self, secret_key: bytes_like, salt: Optional[bytes_like]=None, sep: Optional[str]='', | ||
key_derivation: Optional[str]=None, | ||
digest_method: Optional[Callable]=None, | ||
algorithm: Optional[SigningAlgorithm]=None) -> None: ... | ||
def derive_key(self) -> str: ... | ||
def get_signature(self, value: bytes_like) -> str: ... | ||
def sign(self, value: bytes_like) -> str: ... | ||
def verify_signature(self, value: bytes_like, sig: bytes_like) -> bool: ... | ||
def unsign(self, signed_value: str) -> str: ... | ||
def validate(self, signed_value: str) -> bool: ... | ||
|
||
class TimestampSigner(Signer): | ||
def get_timestamp(self) -> int: ... | ||
def timestamp_to_datetime(self, ts: int) -> datetime: ... | ||
def sign(self, value: bytes_like) -> str: ... | ||
def unsign(self, value: str, max_age: Optional[int]=None, return_timestamp=False) -> Any: ... | ||
def validate(self, signed_value: str, max_age: Optional[int]=None) -> bool: ... | ||
|
||
class Serializer: | ||
default_serializer = ... # type: Any | ||
default_signer = ... # type: Callable[..., Signer] | ||
secret_key = ... # type: Any | ||
salt = ... # type: bytes_like | ||
serializer = ... # type: Any | ||
is_text_serializer = ... # type: bool | ||
signer = ... # type: Signer | ||
signer_kwargs = ... # type: MutableMapping | ||
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: ... | ||
def load_payload(self, payload: Any, serializer=None) -> Any: ... | ||
def dump_payload(self, *args, **kwargs) -> str: ... | ||
def make_signer(self, salt: Optional[bytes_like]=None) -> Signer: ... | ||
def dumps(self, obj: Any, salt: Optional[bytes_like]=None) -> str: ... | ||
def dump(self, obj: Any, f: IO[str], salt: Optional[bytes_like]=None) -> None: ... | ||
def loads(self, s: str, salt: Optional[bytes_like]=None) -> Any: ... | ||
def load(self, f: IO[str], salt: Optional[bytes_like]=None): ... | ||
def loads_unsafe(self, s, salt: Optional[bytes_like]=None) -> Tuple[bool, Any]: ... | ||
def load_unsafe(self, f: IO[str], *args, **kwargs) -> Tuple[bool, Any]: ... | ||
|
||
class TimedSerializer(Serializer): | ||
default_signer = ... # type: Callable[..., TimestampSigner] | ||
def loads(self, s: str, salt: Optional[bytes_like]=None, max_age: Optional[int]=None, return_timestamp=False) -> Any: ... | ||
def loads_unsafe(self, s: str, salt: Optional[bytes_like]=None, max_age: Optional[int]=None) -> Tuple[bool, Any]: ... | ||
|
||
class JSONWebSignatureSerializer(Serializer): | ||
jws_algorithms = ... # type: MutableMapping[str, SigningAlgorithm] | ||
default_algorithm = ... # type: str | ||
default_serializer = ... # type: Any | ||
algorithm_name = ... # type: str | ||
algorithm = ... # type: Any | ||
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: ... | ||
def load_payload(self, payload: Any, return_header=False) -> Any: ... | ||
def dump_payload(self, *args, **kwargs) -> str: ... | ||
def make_algorithm(self, algorithm_name: str) -> SigningAlgorithm: ... | ||
def make_signer(self, salt: Optional[bytes_like]=None, algorithm_name: Optional[str]=None) -> Signer: ... | ||
def make_header(self, header_fields=Optional[MutableMapping]) -> MutableMapping: ... | ||
def dumps(self, obj: Any, salt: Optional[bytes_like]=None, header_fields=Optional[MutableMapping]) -> str: ... | ||
def loads(self, s: str, salt: Optional[bytes_like]=None, return_header=False) -> Any: ... | ||
def loads_unsafe(self, s, salt: Optional[bytes_like]=None, return_header=False) -> Tuple[bool, Any]: ... | ||
|
||
class TimedJSONWebSignatureSerializer(JSONWebSignatureSerializer): | ||
DEFAULT_EXPIRES_IN = ... # type: int | ||
expires_in = ... # type: int | ||
def __init__(self, secret_key: bytes_like, expires_in: Optional[int]=None, **kwargs) -> None: ... | ||
def make_header(self, header_fields=Optional[MutableMapping]) -> MutableMapping: ... | ||
def loads(self, s: str, salt: Optional[bytes_like]=None, return_header=False) -> Any: ... | ||
def get_issue_date(self, header: MutableMapping) -> Optional[datetime]: ... | ||
def now(self) -> int: ... | ||
|
||
class URLSafeSerializerMixin: | ||
def load_payload(self, payload: Any, **kwargs) -> Any: ... | ||
def dump_payload(self, *args, **kwargs) -> str: ... | ||
|
||
class URLSafeSerializer(URLSafeSerializerMixin, Serializer): | ||
default_serializer = ... # type: Any | ||
|
||
class URLSafeTimedSerializer(URLSafeSerializerMixin, TimedSerializer): | ||
default_serializer = ... # type: Any |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
# Stubs for itsdangerous (Python 3) | ||
# | ||
# NOTE: This dynamically typed stub was automatically generated by stubgen. | ||
|
||
from datetime import datetime | ||
from typing import Any, Callable, IO, MutableMapping, Optional, Text, Tuple, TypeVar, Union | ||
|
||
PY2 = ... # type: bool | ||
text_type = str | ||
int_to_byte = Callable[[int], bytes] | ||
number_types = (int, float) | ||
izip = zip | ||
|
||
bytes_like = Union[bytearray, bytes] | ||
str_like = Union[str, bytes] | ||
can_become_bytes = Union[str, bytes, bytearray] | ||
comparable_bytes = TypeVar('comparable_bytes', str, Union[bytes, bytearray]) | ||
|
||
class _CompactJSON: | ||
def loads(self, payload: Text) -> Any: ... | ||
def dumps(self, obj: Any) -> Text: ... | ||
|
||
compact_json = _CompactJSON | ||
EPOCH = ... # type: int | ||
|
||
def want_bytes(s: can_become_bytes, encoding='', errors='') -> bytes: ... | ||
def is_text_serializer(serializer: Any) -> bool: ... | ||
def constant_time_compare(val1: comparable_bytes, val2: comparable_bytes) -> bool: ... | ||
|
||
class BadData(Exception): | ||
message = ... # type: str | ||
def __init__(self, message: str) -> None: ... | ||
|
||
class BadPayload(BadData): | ||
original_error = ... # type: Optional[Exception] | ||
def __init__(self, message: str, original_error: Optional[Exception]=None) -> None: ... | ||
|
||
class BadSignature(BadData): | ||
payload = ... # type: Optional[Any] | ||
def __init__(self, message: str, payload: Optional[Any]=None) -> None: ... | ||
|
||
class BadTimeSignature(BadSignature): | ||
date_signed = ... # type: Optional[int] | ||
def __init__(self, message, payload: Optional[Any]=None, date_signed: Optional[int]=None) -> None: ... | ||
|
||
class BadHeader(BadSignature): | ||
header = ... # type: Any | ||
original_error = ... # type: Any | ||
def __init__(self, message, payload=None, header=None, original_error=None) -> None: ... | ||
|
||
class SignatureExpired(BadTimeSignature): ... | ||
|
||
def base64_encode(string: can_become_bytes) -> bytes: ... | ||
def base64_decode(string: can_become_bytes) -> bytes: ... | ||
def int_to_bytes(num: int) -> bytes: ... | ||
def bytes_to_int(bytestr: can_become_bytes) -> bytes: ... | ||
|
||
class SigningAlgorithm: | ||
def get_signature(self, key: bytes_like, value: bytes_like) -> bytes: ... | ||
def verify_signature(self, key: bytes_like, value: bytes_like, sig: can_become_bytes) -> bool: ... | ||
|
||
class NoneAlgorithm(SigningAlgorithm): | ||
def get_signature(self, key: bytes_like, value: bytes_like) -> bytes: ... | ||
|
||
class HMACAlgorithm(SigningAlgorithm): | ||
default_digest_method = ... # type: Callable | ||
digest_method = ... # type: Callable | ||
def __init__(self, digest_method: Optional[Callable]=None) -> None: ... | ||
def get_signature(self, key: bytes_like, value: bytes_like) -> bytes: ... | ||
|
||
class Signer: | ||
default_digest_method = ... # type: Callable | ||
default_key_derivation = ... # type: str | ||
secret_key = ... # type: can_become_bytes | ||
sep = ... # type: can_become_bytes | ||
salt = ... # type: can_become_bytes | ||
key_derivation = ... # type: str | ||
digest_method = ... # type: Callable | ||
algorithm = ... # type: SigningAlgorithm | ||
def __init__(self, secret_key: can_become_bytes, salt: Optional[can_become_bytes]=None, sep: Optional[can_become_bytes]='', | ||
key_derivation: Optional[str]=None, | ||
digest_method: Optional[Callable]=None, | ||
algorithm: Optional[SigningAlgorithm]=None) -> None: ... | ||
def derive_key(self) -> bytes: ... | ||
def get_signature(self, value: bytes_like) -> bytes: ... | ||
def sign(self, value: bytes_like) -> bytes: ... | ||
def verify_signature(self, value: bytes_like, sig: can_become_bytes) -> bool: ... | ||
def unsign(self, signed_value: can_become_bytes) -> str: ... | ||
def validate(self, signed_value: can_become_bytes) -> bool: ... | ||
|
||
class TimestampSigner(Signer): | ||
def get_timestamp(self) -> int: ... | ||
def timestamp_to_datetime(self, ts: int) -> datetime: ... | ||
def sign(self, value: bytes_like) -> bytes: ... | ||
def unsign(self, value: can_become_bytes, max_age: Optional[int]=None, return_timestamp=False) -> Any: ... | ||
def validate(self, signed_value: can_become_bytes, max_age: Optional[int]=None) -> bool: ... | ||
|
||
class Serializer: | ||
default_serializer = ... # type: Any | ||
default_signer = ... # type: Callable[..., Signer] | ||
secret_key = ... # type: Any | ||
salt = ... # type: can_become_bytes | ||
serializer = ... # type: Any | ||
is_text_serializer = ... # type: bool | ||
signer = ... # type: Signer | ||
signer_kwargs = ... # type: MutableMapping | ||
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: ... | ||
def load_payload(self, payload: Any, serializer=None) -> Any: ... | ||
def dump_payload(self, *args, **kwargs) -> bytes: ... | ||
def make_signer(self, salt: Optional[can_become_bytes]=None) -> Signer: ... | ||
def dumps(self, obj: Any, salt: Optional[can_become_bytes]=None) -> str_like: ... | ||
def dump(self, obj: Any, f: IO, salt: Optional[can_become_bytes]=None) -> None: ... | ||
def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None) -> Any: ... | ||
def load(self, f: IO, salt: Optional[can_become_bytes]=None): ... | ||
def loads_unsafe(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None) -> Tuple[bool, Any]: ... | ||
def load_unsafe(self, f: IO, *args, **kwargs) -> Tuple[bool, Any]: ... | ||
|
||
class TimedSerializer(Serializer): | ||
default_signer = ... # type: Callable[..., TimestampSigner] | ||
def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, max_age: Optional[int]=None, return_timestamp=False) -> Any: ... | ||
def loads_unsafe(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, max_age: Optional[int]=None) -> Tuple[bool, Any]: ... | ||
|
||
class JSONWebSignatureSerializer(Serializer): | ||
jws_algorithms = ... # type: MutableMapping[str, SigningAlgorithm] | ||
default_algorithm = ... # type: str | ||
default_serializer = ... # type: Any | ||
algorithm_name = ... # type: str | ||
algorithm = ... # type: Any | ||
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: ... | ||
def load_payload(self, payload: Any, return_header=False) -> Any: ... | ||
def dump_payload(self, *args, **kwargs) -> bytes: ... | ||
def make_algorithm(self, algorithm_name: str) -> SigningAlgorithm: ... | ||
def make_signer(self, salt: Optional[can_become_bytes]=None, algorithm_name: Optional[str]=None) -> Signer: ... | ||
def make_header(self, header_fields=Optional[MutableMapping]) -> MutableMapping: ... | ||
def dumps(self, obj: Any, salt: Optional[can_become_bytes]=None, header_fields=Optional[MutableMapping]) -> str: ... | ||
def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, return_header=False) -> Any: ... | ||
def loads_unsafe(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, return_header=False) -> Tuple[bool, Any]: ... | ||
|
||
class TimedJSONWebSignatureSerializer(JSONWebSignatureSerializer): | ||
DEFAULT_EXPIRES_IN = ... # type: int | ||
expires_in = ... # type: int | ||
def __init__(self, secret_key: can_become_bytes, expires_in: Optional[int]=None, **kwargs) -> None: ... | ||
def make_header(self, header_fields=Optional[MutableMapping]) -> MutableMapping: ... | ||
def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, return_header=False) -> Any: ... | ||
def get_issue_date(self, header: MutableMapping) -> Optional[datetime]: ... | ||
def now(self) -> int: ... | ||
|
||
class URLSafeSerializerMixin: | ||
def load_payload(self, payload: Any, **kwargs) -> Any: ... | ||
def dump_payload(self, *args, **kwargs) -> bytes: ... | ||
|
||
class URLSafeSerializer(URLSafeSerializerMixin, Serializer): | ||
default_serializer = ... # type: Any | ||
|
||
class URLSafeTimedSerializer(URLSafeSerializerMixin, TimedSerializer): | ||
default_serializer = ... # type: Any |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... I wonder if even for 2.7 it's better to use bytes instead of str? Honestly I have no idea what this package does (and no time to research it) so if you don't think that's a good idea I'll take your word for it. If you do, maybe it should go into 2and3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's an interesting idea. I forgot that
bytes
aliases tostr
in Python 2. The main motivation for splitting things up is it actually gets quite complicated in Python 3 as to which methods can take strings and which ones have to take abytes_like
value. I'll investigate unifying the stybs.