Skip to content

Commit 7f92107

Browse files
authored
Sync typeshed (#10537)
Source commit: python/typeshed@c4da375 Co-authored-by: hauntsaninja <>
1 parent 9f6b373 commit 7f92107

File tree

414 files changed

+16778
-4697
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

414 files changed

+16778
-4697
lines changed

mypy/fastparse.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ def transform_args(self,
660660
) -> List[Argument]:
661661
new_args = []
662662
names = [] # type: List[ast3.arg]
663-
args_args = getattr(args, "posonlyargs", []) + args.args
663+
args_args = getattr(args, "posonlyargs", cast(List[ast3.arg], [])) + args.args
664664
args_defaults = args.defaults
665665
num_no_defaults = len(args_args) - len(args_defaults)
666666
# positional arguments without defaults

mypy/typeshed/stdlib/@python2/Queue.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from collections import deque
21
from typing import Any, Deque, Generic, Optional, TypeVar
32

43
_T = TypeVar("_T")

mypy/typeshed/stdlib/@python2/SocketServer.pyi

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import sys
2-
import types
32
from socket import SocketType
4-
from typing import Any, BinaryIO, Callable, ClassVar, List, Optional, Text, Tuple, Type, Union
3+
from typing import Any, BinaryIO, Callable, ClassVar, List, Optional, Text, Tuple, Union
54

65
class BaseServer:
76
address_family: int

mypy/typeshed/stdlib/@python2/UserString.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import collections
21
from typing import Any, Iterable, List, MutableSequence, Optional, Sequence, Text, Tuple, TypeVar, Union, overload
32

43
_UST = TypeVar("_UST", bound=UserString)

mypy/typeshed/stdlib/@python2/__builtin__.pyi

+6-1
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,12 @@ def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ..
861861
@overload
862862
def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ...
863863
def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode
864-
def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ...
864+
@overload
865+
def getattr(__o: Any, name: Text) -> Any: ...
866+
@overload
867+
def getattr(__o: Any, name: Text, __default: None) -> Optional[Any]: ...
868+
@overload
869+
def getattr(__o: Any, name: Text, __default: _T) -> Union[Any, _T]: ...
865870
def globals() -> Dict[str, Any]: ...
866871
def hasattr(__obj: Any, __name: Text) -> bool: ...
867872
def hash(__obj: object) -> int: ...
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import sys
2+
from typing import List
3+
4+
class _Feature:
5+
def __init__(self, optionalRelease: sys._version_info, mandatoryRelease: sys._version_info, compiler_flag: int) -> None: ...
6+
def getOptionalRelease(self) -> sys._version_info: ...
7+
def getMandatoryRelease(self) -> sys._version_info: ...
8+
compiler_flag: int
9+
10+
absolute_import: _Feature
11+
division: _Feature
12+
generators: _Feature
13+
nested_scopes: _Feature
14+
print_function: _Feature
15+
unicode_literals: _Feature
16+
with_statement: _Feature
17+
all_feature_names: List[str] # undocumented
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Any
2+
3+
def __getattr__(name: str) -> Any: ...
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from typing import MutableSequence, Optional, Sequence, TypeVar
2+
3+
_T = TypeVar("_T")
4+
5+
def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ...
6+
def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ...
7+
def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ...
8+
def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ...
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import codecs
2+
import sys
3+
from typing import Any, Callable, Dict, Optional, Text, Tuple, Union
4+
5+
# For convenience:
6+
_Handler = Callable[[Exception], Tuple[Text, int]]
7+
_String = Union[bytes, str]
8+
_Errors = Union[str, Text, None]
9+
_Decodable = Union[bytes, Text]
10+
_Encodable = Union[bytes, Text]
11+
12+
# This type is not exposed; it is defined in unicodeobject.c
13+
class _EncodingMap(object):
14+
def size(self) -> int: ...
15+
16+
_MapT = Union[Dict[int, int], _EncodingMap]
17+
18+
def register(__search_function: Callable[[str], Any]) -> None: ...
19+
def register_error(__errors: Union[str, Text], __handler: _Handler) -> None: ...
20+
def lookup(__encoding: Union[str, Text]) -> codecs.CodecInfo: ...
21+
def lookup_error(__name: Union[str, Text]) -> _Handler: ...
22+
def decode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ...
23+
def encode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ...
24+
def charmap_build(__map: Text) -> _MapT: ...
25+
def ascii_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ...
26+
def ascii_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
27+
def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
28+
def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[Text, int]: ...
29+
def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ...
30+
def escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[str, int]: ...
31+
def escape_encode(__data: bytes, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
32+
def latin_1_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ...
33+
def latin_1_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
34+
def raw_unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ...
35+
def raw_unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
36+
def readbuffer_encode(__data: _String, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
37+
def unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ...
38+
def unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
39+
def unicode_internal_decode(__obj: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ...
40+
def unicode_internal_encode(__obj: _String, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
41+
def utf_16_be_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
42+
def utf_16_be_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
43+
def utf_16_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
44+
def utf_16_encode(__str: _Encodable, __errors: _Errors = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
45+
def utf_16_ex_decode(
46+
__data: _Decodable, __errors: _Errors = ..., __byteorder: int = ..., __final: int = ...
47+
) -> Tuple[Text, int, int]: ...
48+
def utf_16_le_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
49+
def utf_16_le_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
50+
def utf_32_be_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
51+
def utf_32_be_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
52+
def utf_32_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
53+
def utf_32_encode(__str: _Encodable, __errors: _Errors = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
54+
def utf_32_ex_decode(
55+
__data: _Decodable, __errors: _Errors = ..., __byteorder: int = ..., __final: int = ...
56+
) -> Tuple[Text, int, int]: ...
57+
def utf_32_le_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
58+
def utf_32_le_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
59+
def utf_7_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
60+
def utf_7_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
61+
def utf_8_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
62+
def utf_8_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
63+
64+
if sys.platform == "win32":
65+
def mbcs_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
66+
def mbcs_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from typing import Any, Iterable, Iterator, List, Optional, Protocol, Sequence, Text, Type, Union
2+
3+
QUOTE_ALL: int
4+
QUOTE_MINIMAL: int
5+
QUOTE_NONE: int
6+
QUOTE_NONNUMERIC: int
7+
8+
class Error(Exception): ...
9+
10+
class Dialect:
11+
delimiter: str
12+
quotechar: Optional[str]
13+
escapechar: Optional[str]
14+
doublequote: bool
15+
skipinitialspace: bool
16+
lineterminator: str
17+
quoting: int
18+
strict: int
19+
def __init__(self) -> None: ...
20+
21+
_DialectLike = Union[str, Dialect, Type[Dialect]]
22+
23+
class _reader(Iterator[List[str]]):
24+
dialect: Dialect
25+
line_num: int
26+
def next(self) -> List[str]: ...
27+
28+
class _writer:
29+
dialect: Dialect
30+
def writerow(self, row: Sequence[Any]) -> Any: ...
31+
def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ...
32+
33+
class _Writer(Protocol):
34+
def write(self, s: str) -> Any: ...
35+
36+
def writer(csvfile: _Writer, dialect: _DialectLike = ..., **fmtparams: Any) -> _writer: ...
37+
def reader(csvfile: Iterable[Text], dialect: _DialectLike = ..., **fmtparams: Any) -> _reader: ...
38+
def register_dialect(name: str, dialect: Any = ..., **fmtparams: Any) -> None: ...
39+
def unregister_dialect(name: str) -> None: ...
40+
def get_dialect(name: str) -> Dialect: ...
41+
def list_dialects() -> List[str]: ...
42+
def field_size_limit(new_limit: int = ...) -> int: ...

0 commit comments

Comments
 (0)