Add stubs for markupsafe (#718)

* Add stubs for markupsafe
* Add more specific types for markupsafe

This is needed for Flask. Permission was given here:
https://github.com/pallets/itsdangerous/issues/69#issuecomment-246516942
This commit is contained in:
Roy Williams
2016-11-29 13:32:12 -08:00
committed by Łukasz Langa
parent bbbf1d8c7a
commit 1dff8e4a45
5 changed files with 110 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
# Stubs for markupsafe (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
import sys
from typing import Any, Callable, Iterable, List, Optional, Text, Tuple, Union
from collections import Mapping
from markupsafe._compat import text_type
import string
from markupsafe._speedups import escape as escape, escape_silent as escape_silent, soft_unicode as soft_unicode
from markupsafe._native import escape as escape, escape_silent as escape_silent, soft_unicode as soft_unicode
class Markup(text_type):
def __new__(cls, base: Text = ..., encoding: Optional[Text] = ..., errors: Text = ...) -> Markup: ...
def __html__(self) -> Markup: ...
def __add__(self, other: text_type) -> Markup: ...
def __radd__(self, other: text_type) -> Markup: ...
def __mul__(self, num: int) -> Markup: ...
def __rmul__(self, num: int) -> Markup: ...
def __mod__(self, *args: Any) -> Markup: ...
def join(self, seq: Iterable[text_type]): ...
def split(self, sep: text_type = None, maxsplit: int = -1) -> List[text_type]: ...
def rsplit(self, sep: text_type = None, maxsplit: int = -1) -> List[text_type]: ...
def splitlines(self, keepends: bool = ...) -> List[text_type]: ...
def unescape(self) -> Text: ...
def striptags(self) -> Text: ...
@classmethod
def escape(cls, s: text_type) -> Markup: ...
def partition(self, sep: text_type) -> Tuple[Markup, Markup, Markup]: ...
def rpartition(self, sep: text_type) -> Tuple[Markup, Markup, Markup]: ...
def format(*args, **kwargs) -> Markup: ...
def __html_format__(self, format_spec) -> Markup: ...
def __getslice__(self, start: int, stop: int) -> Markup: ...
def __getitem__(self, i: Union[int, slice]) -> Markup: ...
def capitalize(self) -> Markup: ...
def title(self) -> Markup: ...
def lower(self) -> Markup: ...
def upper(self) -> Markup: ...
def swapcase(self) -> Markup: ...
def replace(self, old: text_type, new: text_type, count: int = -1) -> Markup: ...
def ljust(self, width: int, fillchar: text_type = ...) -> Markup: ...
def rjust(self, width: int, fillchar: text_type = ...) -> Markup: ...
def lstrip(self, chars: text_type = None) -> Markup: ...
def rstrip(self, chars: text_type = None) -> Markup: ...
def strip(self, chars: text_type = None) -> Markup: ...
def center(self, width: int, fillchar: text_type = ...) -> Markup: ...
def zfill(self, width: int) -> Markup: ...
def translate(self, table: Union[Dict[int, Any], text_type]) -> Markup: ...
def expandtabs(self, tabsize: int = 8) -> Markup: ...
class EscapeFormatter(string.Formatter):
escape = ... # type: Callable[[text_type], Markup]
def __init__(self, escape: Callable[[text_type], Markup]) -> None: ...
def format_field(self, value: text_type, format_spec: text_type) -> Markup: ...
if sys.version_info[0] >= 3:
soft_str = soft_unicode

View File

@@ -0,0 +1,23 @@
# Stubs for markupsafe._compat (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
import sys
from typing import Any, Iterator, Mapping, Text, Tuple, TypeVar
_K = TypeVar('_K')
_V = TypeVar('_V')
PY2 = ... # type: bool
def iteritems(d: Mapping[_K, _V]) -> Iterator[Tuple[_K, _V]]: ...
if sys.version_info[0] >= 3:
text_type = str
string_types = str,
unichr = chr
int_types = int,
else:
text_type = unicode
string_types = (str, unicode)
unichr = __builtins__.unichr
int_types = (int, long)

View File

@@ -0,0 +1,7 @@
# Stubs for markupsafe._constants (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any, Dict, Text
HTML_ENTITIES = ... # type: Dict[Text, int]

View File

@@ -0,0 +1,11 @@
# Stubs for markupsafe._native (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from . import Markup
from ._compat import text_type, string_types
from typing import Union, Text
def escape(s: Union[Markup, Text]) -> Markup: ...
def escape_silent(s: Union[None, Markup, Text]) -> Markup: ...
def soft_unicode(s: Text) -> text_type: ...

View File

@@ -0,0 +1,11 @@
# Stubs for markupsafe._speedups (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from . import Markup
from ._compat import text_type, string_types
from typing import Union, Text
def escape(s: Union[Markup, Text]) -> Markup: ...
def escape_silent(s: Union[None, Markup, Text]) -> Markup: ...
def soft_unicode(s: Text) -> text_type: ...