Add unicode support to py2 string.Template. (#2871)

This commit is contained in:
Rebecca Chen
2019-03-16 14:12:36 -07:00
committed by Sebastian Rittau
parent 03878d732a
commit e541cdd1a6

View File

@@ -2,7 +2,7 @@
# Based on http://docs.python.org/3.2/library/string.html
from typing import Mapping, Sequence, Any, Optional, Union, List, Tuple, Iterable, AnyStr
from typing import Any, AnyStr, Iterable, List, Mapping, Optional, overload, Sequence, Text, Tuple, Union
ascii_letters = ... # type: str
ascii_lowercase = ... # type: str
@@ -47,14 +47,18 @@ def center(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ...
def zfill(s: AnyStr, width: int) -> AnyStr: ...
def replace(s: AnyStr, old: AnyStr, new: AnyStr, maxreplace: int = ...) -> AnyStr: ...
class Template(object):
# TODO: Unicode support?
template = ... # type: str
class Template:
template: Text
def __init__(self, template: str) -> None: ...
def substitute(self, mapping: Mapping[str, str] = ..., **kwds: str) -> str: ...
def safe_substitute(self, mapping: Mapping[str, str] = ...,
**kwds: str) -> str: ...
def __init__(self, template: Text) -> None: ...
@overload
def substitute(self, mapping: Mapping[Text, str] = ..., **kwds: str) -> str: ...
@overload
def substitute(self, mapping: Mapping[Text, Text] = ..., **kwds: Text) -> Text: ...
@overload
def safe_substitute(self, mapping: Mapping[Text, str] = ..., **kwds: str) -> str: ...
@overload
def safe_substitute(self, mapping: Mapping[Text, Text] = ..., **kwds: Text) -> Text: ...
# TODO(MichalPokorny): This is probably badly and/or loosely typed.
class Formatter(object):