Avoid using string literals in type annotations (#2294)

This commit is contained in:
Yusuke Miyazaki
2018-07-03 12:23:29 +09:00
committed by Jelle Zijlstra
parent 25ad95de4f
commit 6192cce9d9
50 changed files with 175 additions and 175 deletions

View File

@@ -7,10 +7,10 @@ xpath_tokenizer_re = ... # type: Pattern
_token = Tuple[str, str]
_next = Callable[[], _token]
_callback = Callable[['_SelectorContext', List[Element]], Generator[Element, None, None]]
_callback = Callable[[_SelectorContext, List[Element]], Generator[Element, None, None]]
def xpath_tokenizer(pattern: str, namespaces: Dict[str, str]=...) -> Generator[_token, None, None]: ...
def get_parent_map(context: '_SelectorContext') -> Dict[Element, Element]: ...
def get_parent_map(context: _SelectorContext) -> Dict[Element, Element]: ...
def prepare_child(next: _next, token: _token) -> _callback: ...
def prepare_star(next: _next, token: _token) -> _callback: ...
def prepare_self(next: _next, token: _token) -> _callback: ...

View File

@@ -8,7 +8,7 @@ VERSION = ... # type: str
class ParseError(SyntaxError): ...
def iselement(element: 'Element') -> bool: ...
def iselement(element: Element) -> bool: ...
_T = TypeVar('_T')
@@ -41,45 +41,45 @@ else:
# On the bright side, tostring and tostringlist always return bytes:
_tostring_result_type = bytes
class Element(MutableSequence['Element']):
class Element(MutableSequence[Element]):
tag = ... # type: _str_result_type
attrib = ... # type: Dict[_str_result_type, _str_result_type]
text = ... # type: Optional[_str_result_type]
tail = ... # type: Optional[_str_result_type]
def __init__(self, tag: Union[_str_argument_type, Callable[..., 'Element']], attrib: Dict[_str_argument_type, _str_argument_type]=..., **extra: _str_argument_type) -> None: ...
def append(self, subelement: 'Element') -> None: ...
def __init__(self, tag: Union[_str_argument_type, Callable[..., Element]], attrib: Dict[_str_argument_type, _str_argument_type]=..., **extra: _str_argument_type) -> None: ...
def append(self, subelement: Element) -> None: ...
def clear(self) -> None: ...
def copy(self) -> 'Element': ...
def extend(self, elements: Iterable['Element']) -> None: ...
def find(self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type]=...) -> Optional['Element']: ...
def findall(self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type]=...) -> List['Element']: ...
def copy(self) -> Element: ...
def extend(self, elements: Iterable[Element]) -> None: ...
def find(self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type]=...) -> Optional[Element]: ...
def findall(self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type]=...) -> List[Element]: ...
def findtext(self, path: _str_argument_type, default: _T=..., namespaces: Dict[_str_argument_type, _str_argument_type]=...) -> Union[_T, _str_result_type]: ...
def get(self, key: _str_argument_type, default: _T=...) -> Union[_str_result_type, _T]: ...
def getchildren(self) -> List['Element']: ...
def getiterator(self, tag: _str_argument_type=...) -> List['Element']: ...
def getchildren(self) -> List[Element]: ...
def getiterator(self, tag: _str_argument_type=...) -> List[Element]: ...
if sys.version_info >= (3, 2):
def insert(self, index: int, subelement: 'Element') -> None: ...
def insert(self, index: int, subelement: Element) -> None: ...
else:
def insert(self, index: int, element: 'Element') -> None: ...
def insert(self, index: int, element: Element) -> None: ...
def items(self) -> ItemsView[_str_result_type, _str_result_type]: ...
def iter(self, tag: _str_argument_type=...) -> Generator['Element', None, None]: ...
def iterfind(self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type]=...) -> List['Element']: ...
def iter(self, tag: _str_argument_type=...) -> Generator[Element, None, None]: ...
def iterfind(self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type]=...) -> List[Element]: ...
def itertext(self) -> Generator[_str_result_type, None, None]: ...
def keys(self) -> KeysView[_str_result_type]: ...
def makeelement(self, tag: _str_argument_type, attrib: Dict[_str_argument_type, _str_argument_type]) -> 'Element': ...
def remove(self, subelement: 'Element') -> None: ...
def makeelement(self, tag: _str_argument_type, attrib: Dict[_str_argument_type, _str_argument_type]) -> Element: ...
def remove(self, subelement: Element) -> None: ...
def set(self, key: _str_argument_type, value: _str_argument_type) -> None: ...
def __bool__(self) -> bool: ...
def __delitem__(self, i: Union[int, slice]) -> None: ...
@overload
def __getitem__(self, i: int) -> 'Element': ...
def __getitem__(self, i: int) -> Element: ...
@overload
def __getitem__(self, s: slice) -> Sequence['Element']: ...
def __getitem__(self, s: slice) -> Sequence[Element]: ...
def __len__(self) -> int: ...
@overload
def __setitem__(self, i: int, o: 'Element') -> None: ...
def __setitem__(self, i: int, o: Element) -> None: ...
@overload
def __setitem__(self, s: slice, o: Iterable['Element']) -> None: ...
def __setitem__(self, s: slice, o: Iterable[Element]) -> None: ...
def SubElement(parent: Element, tag: _str_argument_type, attrib: Dict[_str_argument_type, _str_argument_type]=..., **extra: _str_argument_type) -> Element: ...
@@ -98,7 +98,7 @@ _file_or_filename = Union[str, bytes, int, IO[Any]]
class ElementTree:
def __init__(self, element: Element=..., file: _file_or_filename=...) -> None: ...
def getroot(self) -> Element: ...
def parse(self, source: _file_or_filename, parser: 'XMLParser'=...) -> Element: ...
def parse(self, source: _file_or_filename, parser: XMLParser=...) -> Element: ...
def iter(self, tag: _str_argument_type=...) -> Generator[Element, None, None]: ...
def getiterator(self, tag: _str_argument_type=...) -> List[Element]: ...
def find(self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type]=...) -> Optional[Element]: ...
@@ -119,23 +119,23 @@ else:
def tostring(element: Element, encoding: str=..., method: str=...) -> _tostring_result_type: ...
def tostringlist(element: Element, encoding: str=..., method: str=...) -> List[_tostring_result_type]: ...
def dump(elem: Element) -> None: ...
def parse(source: _file_or_filename, parser: 'XMLParser'=...) -> ElementTree: ...
def iterparse(source: _file_or_filename, events: Sequence[str]=..., parser: 'XMLParser'=...) -> Iterator[Tuple[str, Any]]: ...
def parse(source: _file_or_filename, parser: XMLParser=...) -> ElementTree: ...
def iterparse(source: _file_or_filename, events: Sequence[str]=..., parser: XMLParser=...) -> Iterator[Tuple[str, Any]]: ...
if sys.version_info >= (3, 4):
class XMLPullParser:
def __init__(self, events: Sequence[str]=..., *, _parser: 'XMLParser'=...) -> None: ...
def __init__(self, events: Sequence[str]=..., *, _parser: XMLParser=...) -> None: ...
def feed(self, data: bytes) -> None: ...
def close(self) -> None: ...
def read_events(self) -> Iterator[Tuple[str, Element]]: ...
def XML(text: _parser_input_type, parser: 'XMLParser'=...) -> Element: ...
def XMLID(text: _parser_input_type, parser: 'XMLParser'=...) -> Tuple[Element, Dict[_str_result_type, Element]]: ...
def XML(text: _parser_input_type, parser: XMLParser=...) -> Element: ...
def XMLID(text: _parser_input_type, parser: XMLParser=...) -> Tuple[Element, Dict[_str_result_type, Element]]: ...
# This is aliased to XML in the source.
fromstring = XML
def fromstringlist(sequence: Sequence[_parser_input_type], parser: 'XMLParser'=...) -> Element: ...
def fromstringlist(sequence: Sequence[_parser_input_type], parser: XMLParser=...) -> Element: ...
# This type is both not precise enough and too precise. The TreeBuilder
# requires the elementfactory to accept tag and attrs in its args and produce