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

@@ -67,7 +67,7 @@ class DictReader(Iterator[_DRMapping]):
def __init__(self, f: Iterable[str], fieldnames: Sequence[str] = ...,
restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ...,
*args: Any, **kwds: Any) -> None: ...
def __iter__(self) -> 'DictReader': ...
def __iter__(self) -> DictReader: ...
if sys.version_info >= (3,):
def __next__(self) -> _DRMapping: ...
else:

View File

@@ -37,10 +37,10 @@ class Fraction(Rational):
def __init__(self, value: str, *, _normalize: bool = ...) -> None: ...
@classmethod
def from_float(cls, f: float) -> 'Fraction': ...
def from_float(cls, f: float) -> Fraction: ...
@classmethod
def from_decimal(cls, dec: Decimal) -> 'Fraction': ...
def limit_denominator(self, max_denominator: int = ...) -> 'Fraction': ...
def from_decimal(cls, dec: Decimal) -> Fraction: ...
def limit_denominator(self, max_denominator: int = ...) -> Fraction: ...
@property
def numerator(self) -> int: ...
@@ -67,9 +67,9 @@ class Fraction(Rational):
def __pow__(self, other): ...
def __rpow__(self, other): ...
def __pos__(self) -> 'Fraction': ...
def __neg__(self) -> 'Fraction': ...
def __abs__(self) -> 'Fraction': ...
def __pos__(self) -> Fraction: ...
def __neg__(self) -> Fraction: ...
def __abs__(self) -> Fraction: ...
def __trunc__(self) -> int: ...
if sys.version_info >= (3, 0):
def __floor__(self) -> int: ...
@@ -90,7 +90,7 @@ class Fraction(Rational):
# Not actually defined within fractions.py, but provides more useful
# overrides
@property
def real(self) -> 'Fraction': ...
def real(self) -> Fraction: ...
@property
def imag(self) -> 'Fraction': ...
def conjugate(self) -> 'Fraction': ...
def imag(self) -> Fraction: ...
def conjugate(self) -> Fraction: ...

View File

@@ -17,7 +17,7 @@ if sys.version_info >= (3, 5):
else:
_ExcInfoType = Union[None, bool, _SysExcInfoType]
_ArgsType = Union[Tuple[Any, ...], Dict[str, Any]]
_FilterType = Union['Filter', Callable[['LogRecord'], int]]
_FilterType = Union[Filter, Callable[[LogRecord], int]]
_Level = Union[int, Text]
raiseExceptions: bool
@@ -33,7 +33,7 @@ class Filterer(object):
def __init__(self) -> None: ...
def addFilter(self, filter: Filter) -> None: ...
def removeFilter(self, filter: Filter) -> None: ...
def filter(self, record: 'LogRecord') -> bool: ...
def filter(self, record: LogRecord) -> bool: ...
class Logger(Filterer):
name = ... # type: str
@@ -46,7 +46,7 @@ class Logger(Filterer):
def setLevel(self, lvl: Union[int, str]) -> None: ...
def isEnabledFor(self, lvl: int) -> bool: ...
def getEffectiveLevel(self) -> int: ...
def getChild(self, suffix: str) -> 'Logger': ...
def getChild(self, suffix: str) -> Logger: ...
if sys.version_info >= (3,):
def debug(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ...,
stack_info: bool = ..., extra: Optional[Dict[str, Any]] = ...,
@@ -99,14 +99,14 @@ class Logger(Filterer):
extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ...
def addFilter(self, filt: _FilterType) -> None: ...
def removeFilter(self, filt: _FilterType) -> None: ...
def filter(self, record: 'LogRecord') -> bool: ...
def addHandler(self, hdlr: 'Handler') -> None: ...
def removeHandler(self, hdlr: 'Handler') -> None: ...
def filter(self, record: LogRecord) -> bool: ...
def addHandler(self, hdlr: Handler) -> None: ...
def removeHandler(self, hdlr: Handler) -> None: ...
if sys.version_info >= (3,):
def findCaller(self, stack_info: bool = ...) -> Tuple[str, int, str, Optional[str]]: ...
else:
def findCaller(self) -> Tuple[str, int, str]: ...
def handle(self, record: 'LogRecord') -> None: ...
def handle(self, record: LogRecord) -> None: ...
if sys.version_info >= (3,):
def makeRecord(self, name: str, lvl: int, fn: str, lno: int, msg: Any,
args: Mapping[str, Any],
@@ -144,16 +144,16 @@ class Handler(Filterer):
def acquire(self) -> None: ...
def release(self) -> None: ...
def setLevel(self, lvl: Union[int, str]) -> None: ...
def setFormatter(self, form: 'Formatter') -> None: ...
def setFormatter(self, form: Formatter) -> None: ...
def addFilter(self, filt: _FilterType) -> None: ...
def removeFilter(self, filt: _FilterType) -> None: ...
def filter(self, record: 'LogRecord') -> bool: ...
def filter(self, record: LogRecord) -> bool: ...
def flush(self) -> None: ...
def close(self) -> None: ...
def handle(self, record: 'LogRecord') -> None: ...
def handleError(self, record: 'LogRecord') -> None: ...
def format(self, record: 'LogRecord') -> str: ...
def emit(self, record: 'LogRecord') -> None: ...
def handle(self, record: LogRecord) -> None: ...
def handleError(self, record: LogRecord) -> None: ...
def format(self, record: LogRecord) -> str: ...
def emit(self, record: LogRecord) -> None: ...
class Formatter:
@@ -174,8 +174,8 @@ class Formatter:
fmt: Optional[str] = ...,
datefmt: Optional[str] =...) -> None: ...
def format(self, record: 'LogRecord') -> str: ...
def formatTime(self, record: 'LogRecord', datefmt: str = ...) -> str: ...
def format(self, record: LogRecord) -> str: ...
def formatTime(self, record: LogRecord, datefmt: str = ...) -> str: ...
def formatException(self, exc_info: _SysExcInfoType) -> str: ...
if sys.version_info >= (3,):
def formatStack(self, stack_info: str) -> str: ...
@@ -183,7 +183,7 @@ class Formatter:
class Filter:
def __init__(self, name: str = ...) -> None: ...
def filter(self, record: 'LogRecord') -> int: ...
def filter(self, record: LogRecord) -> int: ...
class LogRecord:
@@ -362,7 +362,7 @@ if sys.version_info >= (3,):
if sys.version_info >= (3,):
lastResort = ... # type: Optional['StreamHandler']
lastResort = ... # type: Optional[StreamHandler]
class StreamHandler(Handler):

View File

@@ -4,7 +4,7 @@ from typing import List, Union, Sequence, Optional, Dict
class Class:
module = ... # type: str
name = ... # type: str
super = ... # type: Optional[List[Union["Class", str]]]
super = ... # type: Optional[List[Union[Class, str]]]
methods = ... # type: Dict[str, int]
file = ... # type: int
lineno = ... # type: int
@@ -12,7 +12,7 @@ class Class:
def __init__(self,
module: str,
name: str,
super: Optional[List[Union["Class", str]]],
super: Optional[List[Union[Class, str]]],
file: str,
lineno: int) -> None: ...

View File

@@ -521,7 +521,7 @@ class socket:
# --- methods ---
# second tuple item is an address
def accept(self) -> Tuple['socket', Any]: ...
def accept(self) -> Tuple[socket, Any]: ...
def bind(self, address: Union[tuple, str, bytes]) -> None: ...
def close(self) -> None: ...
def connect(self, address: Union[tuple, str, bytes]) -> None: ...

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