Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync typeshed #10346

Merged
merged 2 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion mypy/test/teststubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,6 @@ def test_get_typeshed_stdlib_modules(self) -> None:
assert "os" in stdlib
assert "os.path" in stdlib
assert "mypy_extensions" not in stdlib
assert "typing_extensions" not in stdlib
assert "asyncio" in stdlib
assert ("dataclasses" in stdlib) == (sys.version_info >= (3, 7))

Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/@python2/UserString.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UserString(Sequence[UserString]):
def count(self, sub: int, start: int = ..., end: int = ...) -> int: ...
def decode(self: _UST, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UST: ...
def encode(self: _UST, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UST: ...
def endswith(self, suffix: Text, start: int = ..., end: int = ...) -> bool: ...
def endswith(self, suffix: Union[Text, Tuple[Text, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ...
def expandtabs(self: _UST, tabsize: int = ...) -> _UST: ...
def find(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
def index(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
Expand All @@ -54,7 +54,7 @@ class UserString(Sequence[UserString]):
def split(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[Text]: ...
def rsplit(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[Text]: ...
def splitlines(self, keepends: int = ...) -> List[Text]: ...
def startswith(self, suffix: Text, start: int = ..., end: int = ...) -> bool: ...
def startswith(self, prefix: Union[Text, Tuple[Text, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ...
def strip(self: _UST, chars: Optional[Text] = ...) -> _UST: ...
def swapcase(self: _UST) -> _UST: ...
def title(self: _UST) -> _UST: ...
Expand Down
20 changes: 15 additions & 5 deletions mypy/typeshed/stdlib/@python2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ class unicode(basestring, Sequence[unicode]):
def count(self, x: unicode) -> int: ...
def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ...
def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ...
def endswith(self, suffix: Union[unicode, Tuple[unicode, ...]], start: int = ..., end: int = ...) -> bool: ...
def endswith(
self, __suffix: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> unicode: ...
def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ...
def format(self, *args: object, **kwargs: object) -> unicode: ...
Expand Down Expand Up @@ -326,7 +328,9 @@ class unicode(basestring, Sequence[unicode]):
def rstrip(self, chars: unicode = ...) -> unicode: ...
def split(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ...
def splitlines(self, keepends: bool = ...) -> List[unicode]: ...
def startswith(self, prefix: Union[unicode, Tuple[unicode, ...]], start: int = ..., end: int = ...) -> bool: ...
def startswith(
self, __prefix: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
) -> bool: ...
def strip(self, chars: unicode = ...) -> unicode: ...
def swapcase(self) -> unicode: ...
def title(self) -> unicode: ...
Expand Down Expand Up @@ -369,7 +373,9 @@ class str(Sequence[str], basestring):
def count(self, x: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ...
def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ...
def endswith(self, suffix: Union[Text, Tuple[Text, ...]]) -> bool: ...
def endswith(
self, __suffix: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> str: ...
def find(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def format(self, *args: object, **kwargs: object) -> str: ...
Expand Down Expand Up @@ -418,7 +424,9 @@ class str(Sequence[str], basestring):
@overload
def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ...
def splitlines(self, keepends: bool = ...) -> List[str]: ...
def startswith(self, prefix: Union[Text, Tuple[Text, ...]]) -> bool: ...
def startswith(
self, __prefix: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
) -> bool: ...
@overload
def strip(self, __chars: str = ...) -> str: ...
@overload
Expand Down Expand Up @@ -468,7 +476,9 @@ class bytearray(MutableSequence[int], ByteString):
def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ...
def count(self, __sub: str) -> int: ...
def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ...
def endswith(self, __suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ...
def endswith(
self, __suffix: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> bytearray: ...
def extend(self, iterable: Union[str, Iterable[int]]) -> None: ...
def find(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ...
Expand Down
20 changes: 15 additions & 5 deletions mypy/typeshed/stdlib/@python2/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ class unicode(basestring, Sequence[unicode]):
def count(self, x: unicode) -> int: ...
def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ...
def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ...
def endswith(self, suffix: Union[unicode, Tuple[unicode, ...]], start: int = ..., end: int = ...) -> bool: ...
def endswith(
self, __suffix: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> unicode: ...
def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ...
def format(self, *args: object, **kwargs: object) -> unicode: ...
Expand Down Expand Up @@ -326,7 +328,9 @@ class unicode(basestring, Sequence[unicode]):
def rstrip(self, chars: unicode = ...) -> unicode: ...
def split(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ...
def splitlines(self, keepends: bool = ...) -> List[unicode]: ...
def startswith(self, prefix: Union[unicode, Tuple[unicode, ...]], start: int = ..., end: int = ...) -> bool: ...
def startswith(
self, __prefix: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
) -> bool: ...
def strip(self, chars: unicode = ...) -> unicode: ...
def swapcase(self) -> unicode: ...
def title(self) -> unicode: ...
Expand Down Expand Up @@ -369,7 +373,9 @@ class str(Sequence[str], basestring):
def count(self, x: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ...
def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ...
def endswith(self, suffix: Union[Text, Tuple[Text, ...]]) -> bool: ...
def endswith(
self, __suffix: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> str: ...
def find(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def format(self, *args: object, **kwargs: object) -> str: ...
Expand Down Expand Up @@ -418,7 +424,9 @@ class str(Sequence[str], basestring):
@overload
def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ...
def splitlines(self, keepends: bool = ...) -> List[str]: ...
def startswith(self, prefix: Union[Text, Tuple[Text, ...]]) -> bool: ...
def startswith(
self, __prefix: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
) -> bool: ...
@overload
def strip(self, __chars: str = ...) -> str: ...
@overload
Expand Down Expand Up @@ -468,7 +476,9 @@ class bytearray(MutableSequence[int], ByteString):
def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ...
def count(self, __sub: str) -> int: ...
def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ...
def endswith(self, __suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ...
def endswith(
self, __suffix: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> bytearray: ...
def extend(self, iterable: Union[str, Iterable[int]]) -> None: ...
def find(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ...
Expand Down
109 changes: 109 additions & 0 deletions mypy/typeshed/stdlib/@python2/cgi.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
from _typeshed import SupportsGetItem, SupportsItemAccess
from builtins import type as _type
from typing import IO, Any, AnyStr, Iterable, Iterator, List, Mapping, Optional, Protocol, TypeVar, Union
from UserDict import UserDict

_T = TypeVar("_T", bound=FieldStorage)

def parse(
fp: Optional[IO[Any]] = ...,
environ: SupportsItemAccess[str, str] = ...,
keep_blank_values: bool = ...,
strict_parsing: bool = ...,
) -> dict[str, List[str]]: ...
def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> dict[str, List[str]]: ...
def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> List[tuple[str, str]]: ...
def parse_multipart(fp: IO[Any], pdict: SupportsGetItem[str, bytes]) -> dict[str, List[bytes]]: ...

class _Environ(Protocol):
def __getitem__(self, __k: str) -> str: ...
def keys(self) -> Iterable[str]: ...

def parse_header(line: str) -> tuple[str, dict[str, str]]: ...
def test(environ: _Environ = ...) -> None: ...
def print_environ(environ: _Environ = ...) -> None: ...
def print_form(form: dict[str, Any]) -> None: ...
def print_directory() -> None: ...
def print_environ_usage() -> None: ...
def escape(s: AnyStr, quote: bool = ...) -> AnyStr: ...

class MiniFieldStorage:
# The first five "Any" attributes here are always None, but mypy doesn't support that
filename: Any
list: Any
type: Any
file: Optional[IO[bytes]]
type_options: dict[Any, Any]
disposition: Any
disposition_options: dict[Any, Any]
headers: dict[Any, Any]
name: Any
value: Any
def __init__(self, name: Any, value: Any) -> None: ...
def __repr__(self) -> str: ...

class FieldStorage(object):
FieldStorageClass: Optional[_type]
keep_blank_values: int
strict_parsing: int
qs_on_post: Optional[str]
headers: Mapping[str, str]
fp: IO[bytes]
encoding: str
errors: str
outerboundary: bytes
bytes_read: int
limit: Optional[int]
disposition: str
disposition_options: dict[str, str]
filename: Optional[str]
file: Optional[IO[bytes]]
type: str
type_options: dict[str, str]
innerboundary: bytes
length: int
done: int
list: Optional[List[Any]]
value: Union[None, bytes, List[Any]]
def __init__(
self,
fp: IO[Any] = ...,
headers: Mapping[str, str] = ...,
outerboundary: bytes = ...,
environ: SupportsGetItem[str, str] = ...,
keep_blank_values: int = ...,
strict_parsing: int = ...,
) -> None: ...
def __repr__(self) -> str: ...
def __iter__(self) -> Iterator[str]: ...
def __getitem__(self, key: str) -> Any: ...
def getvalue(self, key: str, default: Any = ...) -> Any: ...
def getfirst(self, key: str, default: Any = ...) -> Any: ...
def getlist(self, key: str) -> List[Any]: ...
def keys(self) -> List[str]: ...
def has_key(self, key: str) -> bool: ...
def __contains__(self, key: str) -> bool: ...
def __len__(self) -> int: ...
def __nonzero__(self) -> bool: ...
# In Python 2 it always returns bytes and ignores the "binary" flag
def make_file(self, binary: Any = ...) -> IO[bytes]: ...

class FormContentDict(UserDict[str, List[str]]):
query_string: str
def __init__(self, environ: Mapping[str, str] = ..., keep_blank_values: int = ..., strict_parsing: int = ...) -> None: ...

class SvFormContentDict(FormContentDict):
def getlist(self, key: Any) -> Any: ...

class InterpFormContentDict(SvFormContentDict): ...

class FormContent(FormContentDict):
# TODO this should have
# def values(self, key: Any) -> Any: ...
# but this is incompatible with the supertype, and adding '# type: ignore' triggers
# a parse error in pytype (https://github.com/google/pytype/issues/53)
def indexed_value(self, key: Any, location: int) -> Any: ...
def value(self, key: Any) -> Any: ...
def length(self, key: Any) -> int: ...
def stripped(self, key: Any) -> Any: ...
def pars(self) -> dict[Any, Any]: ...
Loading