From 7cdc4bfa5ef3bd6d06798d9a7a818692c3f0db6a Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 11 Mar 2019 16:41:11 +0300 Subject: [PATCH 01/16] Making vars argument Optional, as it defaults to None in the code and documentation. --- stdlib/2/ConfigParser.pyi | 6 +++--- stdlib/3/configparser.pyi | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/stdlib/2/ConfigParser.pyi b/stdlib/2/ConfigParser.pyi index 6e6a70e1de1b..693fe3fe1c3a 100644 --- a/stdlib/2/ConfigParser.pyi +++ b/stdlib/2/ConfigParser.pyi @@ -1,4 +1,4 @@ -from typing import Any, IO, Sequence, Tuple, Union, List, Dict, Protocol +from typing import Any, IO, Sequence, Tuple, Union, List, Dict, Protocol, Optional DEFAULTSECT = ... # type: str MAX_INTERPOLATION_DEPTH = ... # type: int @@ -86,8 +86,8 @@ class RawConfigParser: class ConfigParser(RawConfigParser): _KEYCRE = ... # type: Any - def get(self, section: str, option: str, raw: bool = ..., vars: dict = ...) -> Any: ... - def items(self, section: str, raw: bool = ..., vars: dict = ...) -> List[Tuple[str, Any]]: ... + def get(self, section: str, option: str, raw: bool = ..., vars: Optional[dict] = ...) -> Any: ... + def items(self, section: str, raw: bool = ..., vars: Optional[dict] = ...) -> List[Tuple[str, Any]]: ... def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ... def _interpolation_replace(self, match: Any) -> str: ... diff --git a/stdlib/3/configparser.pyi b/stdlib/3/configparser.pyi index 2df7b3381bb6..ef62c0673a2d 100644 --- a/stdlib/3/configparser.pyi +++ b/stdlib/3/configparser.pyi @@ -102,23 +102,23 @@ class RawConfigParser(_parser): # These get* methods are partially applied (with the same names) in # SectionProxy; the stubs should be kept updated together - def getint(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: int = ...) -> int: ... + def getint(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: int = ...) -> int: ... - def getfloat(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: float = ...) -> float: ... + def getfloat(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: float = ...) -> float: ... - def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: bool = ...) -> bool: ... + def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: bool = ...) -> bool: ... - def _get_conv(self, section: str, option: str, conv: Callable[[str], _T], *, raw: bool = ..., vars: _section = ..., fallback: _T = ...) -> _T: ... + def _get_conv(self, section: str, option: str, conv: Callable[[str], _T], *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ...) -> _T: ... # This is incompatible with MutableMapping so we ignore the type - def get(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: str = ...) -> str: # type: ignore + def get(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: str = ...) -> str: # type: ignore ... @overload - def items(self, *, raw: bool = ..., vars: _section = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ... + def items(self, *, raw: bool = ..., vars: Optional[_section] = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ... @overload - def items(self, section: str, raw: bool = ..., vars: _section = ...) -> List[Tuple[str, str]]: ... + def items(self, section: str, raw: bool = ..., vars: Optional[_section] = ...) -> List[Tuple[str, str]]: ... def set(self, section: str, option: str, value: str) -> None: ... @@ -165,9 +165,9 @@ class SectionProxy(MutableMapping[str, str]): # These are partially-applied version of the methods with the same names in # RawConfigParser; the stubs should be kept updated together - def getint(self, option: str, *, raw: bool = ..., vars: _section = ..., fallback: int = ...) -> int: ... - def getfloat(self, option: str, *, raw: bool = ..., vars: _section = ..., fallback: float = ...) -> float: ... - def getboolean(self, option: str, *, raw: bool = ..., vars: _section = ..., fallback: bool = ...) -> bool: ... + def getint(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: int = ...) -> int: ... + def getfloat(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: float = ...) -> float: ... + def getboolean(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: bool = ...) -> bool: ... # SectionProxy can have arbitrary attributes when custon converters are used def __getattr__(self, key: str) -> Callable[..., Any]: ... From 3eed4517c6be61a2514b9b40a90f5ceecd8e794d Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 11 Mar 2019 20:07:39 +0300 Subject: [PATCH 02/16] email.charset.SHORTEST, QP, BASE64 are not in the stub for Python 2 --- stdlib/2/email/charset.pyi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stdlib/2/email/charset.pyi b/stdlib/2/email/charset.pyi index 82ba6c0bbbc5..b60d77c69667 100644 --- a/stdlib/2/email/charset.pyi +++ b/stdlib/2/email/charset.pyi @@ -2,6 +2,10 @@ def add_charset(charset, header_enc=..., body_enc=..., output_charset=...) -> No def add_alias(alias, canonical) -> None: ... def add_codec(charset, codecname) -> None: ... +QP: int +BASE64: int +SHORTEST: int + class Charset: input_charset = ... header_encoding = ... From d065fdfb5350b8b3ac1560567cd0ec45ab516500 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 11 Mar 2019 20:11:51 +0300 Subject: [PATCH 03/16] email.mime.application.MIMEApplication expects data to be bytes, while it should be Union[str, bytes] Fixes #2831 --- stdlib/3/email/mime/application.pyi | 2 +- stdlib/3/email/mime/audio.pyi | 2 +- stdlib/3/email/mime/image.pyi | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/3/email/mime/application.pyi b/stdlib/3/email/mime/application.pyi index 1aa0580ec891..1a40e281f447 100644 --- a/stdlib/3/email/mime/application.pyi +++ b/stdlib/3/email/mime/application.pyi @@ -6,6 +6,6 @@ from email.mime.nonmultipart import MIMENonMultipart _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEApplication(MIMENonMultipart): - def __init__(self, _data: bytes, _subtype: str = ..., + def __init__(self, _data: Union[str, bytes], _subtype: str = ..., _encoder: Callable[[MIMEApplication], None] = ..., **_params: _ParamsType) -> None: ... diff --git a/stdlib/3/email/mime/audio.pyi b/stdlib/3/email/mime/audio.pyi index 2d2c90c2af50..5bb57d3a5d7a 100644 --- a/stdlib/3/email/mime/audio.pyi +++ b/stdlib/3/email/mime/audio.pyi @@ -6,6 +6,6 @@ from email.mime.nonmultipart import MIMENonMultipart _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEAudio(MIMENonMultipart): - def __init__(self, _audiodata: bytes, _subtype: Optional[str] = ..., + def __init__(self, _audiodata: Union[str, bytes], _subtype: Optional[str] = ..., _encoder: Callable[[MIMEAudio], None] = ..., **_params: _ParamsType) -> None: ... diff --git a/stdlib/3/email/mime/image.pyi b/stdlib/3/email/mime/image.pyi index 9ec5deba0916..d32d9ee650fc 100644 --- a/stdlib/3/email/mime/image.pyi +++ b/stdlib/3/email/mime/image.pyi @@ -6,6 +6,6 @@ from email.mime.nonmultipart import MIMENonMultipart _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEImage(MIMENonMultipart): - def __init__(self, _imagedata: bytes, _subtype: Optional[str] = ..., + def __init__(self, _imagedata: Union[str, bytes], _subtype: Optional[str] = ..., _encoder: Callable[[MIMEImage], None] = ..., **_params: _ParamsType) -> None: ... From 73e625fe0de2e69d41cb76019cd8363bb7f0a402 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 11 Mar 2019 20:42:05 +0300 Subject: [PATCH 04/16] Adding #undocumented as requested by @srittau to fix #2830 --- stdlib/2/email/charset.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/2/email/charset.pyi b/stdlib/2/email/charset.pyi index b60d77c69667..53c9166fba53 100644 --- a/stdlib/2/email/charset.pyi +++ b/stdlib/2/email/charset.pyi @@ -2,9 +2,9 @@ def add_charset(charset, header_enc=..., body_enc=..., output_charset=...) -> No def add_alias(alias, canonical) -> None: ... def add_codec(charset, codecname) -> None: ... -QP: int -BASE64: int -SHORTEST: int +QP: int # undocumented +BASE64: int # undocumented +SHORTEST: int # undocumented class Charset: input_charset = ... From 603bf4b887d19669f8897361673fb25f92b26ecf Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 18 Jul 2019 17:53:51 +0300 Subject: [PATCH 05/16] NullTranslations._parse() stub added; Missing return values added; A lot of parameters have been made Optional, according to documentation; translation() stub improved by using @overload --- stdlib/3/gettext.pyi | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/stdlib/3/gettext.pyi b/stdlib/3/gettext.pyi index eeb9b09768f9..f48f4e983c1d 100644 --- a/stdlib/3/gettext.pyi +++ b/stdlib/3/gettext.pyi @@ -1,9 +1,10 @@ # Stubs for gettext (Python 3.4) -from typing import Any, IO, List, Optional, Union, Callable +from typing import overload, Any, IO, Optional, Sequence, Type, TypeVar class NullTranslations: def __init__(self, fp: IO[str] = ...) -> None: ... + def _parse(self, fp: IO[str]) -> None: ... def add_fallback(self, fallback: NullTranslations) -> None: ... def gettext(self, message: str) -> str: ... def lgettext(self, message: str) -> str: ... @@ -12,26 +13,30 @@ class NullTranslations: def info(self) -> Any: ... def charset(self) -> Any: ... def output_charset(self) -> Any: ... - def set_output_charset(self, charset: Any) -> None: ... - def install(self, names: List[str] = ...) -> None: ... + def set_output_charset(self, charset: str) -> None: ... + def install(self, names: Optional[Sequence[str]] = ...) -> None: ... class GNUTranslations(NullTranslations): LE_MAGIC: int BE_MAGIC: int -def find(domain: str, localedir: str = ..., languages: List[str] = ..., - all: bool = ...): ... +def find(domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ..., + all: bool = ...) -> Any: ... -def translation(domain: str, localedir: str = ..., languages: List[str] = ..., - class_: Callable[[IO[str]], NullTranslations] = ..., - fallback: bool = ..., codeset: Any = ...) -> NullTranslations: ... +_T = TypeVar('_T') +@overload +def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ..., + *, fallback: bool = ..., codeset: Optional[str] = ...) -> NullTranslations: ... +@overload +def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ..., + class_: Type[_T] = ..., fallback: bool = ..., codeset: Optional[str] = ...) -> _T: ... -def install(domain: str, localedir: str = ..., codeset: Any = ..., - names: List[str] = ...): ... +def install(domain: str, localedir: Optional[str] = ..., codeset: Optional[str] = ..., + names: Optional[Sequence[str]] = ...) -> None: ... -def textdomain(domain: str = ...) -> str: ... -def bindtextdomain(domain: str, localedir: str = ...) -> str: ... -def bind_textdomain_codeset(domain: str, codeset: str = ...) -> str: ... +def textdomain(domain: Optional[str] = ...) -> str: ... +def bindtextdomain(domain: str, localedir: Optional[str] = ...) -> str: ... +def bind_textdomain_codeset(domain: str, codeset: Optional[str] = ...) -> str: ... def dgettext(domain: str, message: str) -> str: ... def ldgettext(domain: str, message: str) -> str: ... def dngettext(domain: str, singular: str, plural: str, n: int) -> str: ... From 5dc4d4fba307f4c3ef9abb0fa60ab69e71df2e00 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 25 Jul 2019 17:10:53 +0300 Subject: [PATCH 06/16] Update stdlib/3/gettext.pyi Sequence replaced with Container Co-Authored-By: Sebastian Rittau --- stdlib/3/gettext.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/gettext.pyi b/stdlib/3/gettext.pyi index f48f4e983c1d..1e9d4056c08f 100644 --- a/stdlib/3/gettext.pyi +++ b/stdlib/3/gettext.pyi @@ -14,7 +14,7 @@ class NullTranslations: def charset(self) -> Any: ... def output_charset(self) -> Any: ... def set_output_charset(self, charset: str) -> None: ... - def install(self, names: Optional[Sequence[str]] = ...) -> None: ... + def install(self, names: Optional[Container[str]] = ...) -> None: ... class GNUTranslations(NullTranslations): LE_MAGIC: int From 1304aef5ec3ab322321bcd789d9b535ad79245ee Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 25 Jul 2019 17:11:32 +0300 Subject: [PATCH 07/16] Update stdlib/3/gettext.pyi Sequence replaced with Iterable Co-Authored-By: Sebastian Rittau --- stdlib/3/gettext.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/gettext.pyi b/stdlib/3/gettext.pyi index 1e9d4056c08f..9964ce843aa3 100644 --- a/stdlib/3/gettext.pyi +++ b/stdlib/3/gettext.pyi @@ -20,7 +20,7 @@ class GNUTranslations(NullTranslations): LE_MAGIC: int BE_MAGIC: int -def find(domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ..., +def find(domain: str, localedir: Optional[str] = ..., languages: Optional[Iterable[str]] = ..., all: bool = ...) -> Any: ... _T = TypeVar('_T') From a0fbaef75ca3b6def623174d233da58948f84563 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 25 Jul 2019 17:28:18 +0300 Subject: [PATCH 08/16] Suggestions from @srittau implemented --- stdlib/3/gettext.pyi | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/stdlib/3/gettext.pyi b/stdlib/3/gettext.pyi index 9964ce843aa3..7697404fb273 100644 --- a/stdlib/3/gettext.pyi +++ b/stdlib/3/gettext.pyi @@ -1,6 +1,7 @@ # Stubs for gettext (Python 3.4) -from typing import overload, Any, IO, Optional, Sequence, Type, TypeVar +from typing import overload, Any, Container, IO, Iterable, Optional, Type, TypeVar +from typing_extensions import Literal class NullTranslations: def __init__(self, fp: IO[str] = ...) -> None: ... @@ -25,14 +26,17 @@ def find(domain: str, localedir: Optional[str] = ..., languages: Optional[Iterab _T = TypeVar('_T') @overload -def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ..., - *, fallback: bool = ..., codeset: Optional[str] = ...) -> NullTranslations: ... +def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Iterable[str]] = ..., + class_: None = ..., fallback: bool = ..., codeset: Optional[str] = ...) -> NullTranslations: ... @overload -def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ..., - class_: Type[_T] = ..., fallback: bool = ..., codeset: Optional[str] = ...) -> _T: ... +def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Iterable[str]] = ..., + class_: Type[_T] = ..., fallback: Literal[False] = ..., codeset: Optional[str] = ...) -> _T: ... +@overload +def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Iterable[str]] = ..., + class_: Type[_T] = ..., fallback: Literal[True] = ..., codeset: Optional[str] = ...) -> Any: ... def install(domain: str, localedir: Optional[str] = ..., codeset: Optional[str] = ..., - names: Optional[Sequence[str]] = ...) -> None: ... + names: Optional[Container[str]] = ...) -> None: ... def textdomain(domain: Optional[str] = ...) -> str: ... def bindtextdomain(domain: str, localedir: Optional[str] = ...) -> str: ... From 1352f9cf7c504d122a5a919607e671d85efbc829 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 19 Sep 2019 16:56:08 +0300 Subject: [PATCH 09/16] Stubs for maxminddb added, approved by the developer, see https://github.com/maxmind/MaxMind-DB-Reader-python/issues/45 --- third_party/3/maxminddb/__init__.pyi | 9 ++++++++ third_party/3/maxminddb/compat.pyi | 10 +++++++++ third_party/3/maxminddb/const.pyi | 7 ++++++ third_party/3/maxminddb/decoder.pyi | 7 ++++++ third_party/3/maxminddb/errors.pyi | 3 +++ third_party/3/maxminddb/extension.pyi | 26 ++++++++++++++++++++++ third_party/3/maxminddb/reader.pyi | 32 +++++++++++++++++++++++++++ 7 files changed, 94 insertions(+) create mode 100644 third_party/3/maxminddb/__init__.pyi create mode 100644 third_party/3/maxminddb/compat.pyi create mode 100644 third_party/3/maxminddb/const.pyi create mode 100644 third_party/3/maxminddb/decoder.pyi create mode 100644 third_party/3/maxminddb/errors.pyi create mode 100644 third_party/3/maxminddb/extension.pyi create mode 100644 third_party/3/maxminddb/reader.pyi diff --git a/third_party/3/maxminddb/__init__.pyi b/third_party/3/maxminddb/__init__.pyi new file mode 100644 index 000000000000..040872fed4ec --- /dev/null +++ b/third_party/3/maxminddb/__init__.pyi @@ -0,0 +1,9 @@ +# Stubs for maxminddb (Python 3) + +from typing import Any + +from maxminddb import reader + +def open_database(database: str, mode: int = ...) -> reader.Reader: ... + +def Reader(database: str) -> reader.Reader: ... diff --git a/third_party/3/maxminddb/compat.pyi b/third_party/3/maxminddb/compat.pyi new file mode 100644 index 000000000000..11ac8750afc5 --- /dev/null +++ b/third_party/3/maxminddb/compat.pyi @@ -0,0 +1,10 @@ +# Stubs for maxminddb.compat (Python 3) + +from ipaddress import IPv4Address, IPv6Address + +from typing import Any, Union + +def compat_ip_address(address: Any) -> Union[IPv4Address, IPv6Address]: ... +def int_from_byte(x: int) -> int: ... +def int_from_bytes(x: bytes) -> int: ... +def byte_from_int(x: int) -> bytes: ... diff --git a/third_party/3/maxminddb/const.pyi b/third_party/3/maxminddb/const.pyi new file mode 100644 index 000000000000..e5f8af28616e --- /dev/null +++ b/third_party/3/maxminddb/const.pyi @@ -0,0 +1,7 @@ +# Stubs for maxminddb.const (Python 3) + +MODE_AUTO: int +MODE_MMAP_EXT: int +MODE_MMAP: int +MODE_FILE: int +MODE_MEMORY: int diff --git a/third_party/3/maxminddb/decoder.pyi b/third_party/3/maxminddb/decoder.pyi new file mode 100644 index 000000000000..1b7aa6e154a6 --- /dev/null +++ b/third_party/3/maxminddb/decoder.pyi @@ -0,0 +1,7 @@ +# Stubs for maxminddb.decoder (Python 3) + +from typing import Any, Tuple + +class Decoder: + def __init__(self, database_buffer: bytes, pointer_base: int = ..., pointer_test: bool = ...) -> None: ... + def decode(self, offset: int) -> Tuple[Any, int]: ... diff --git a/third_party/3/maxminddb/errors.pyi b/third_party/3/maxminddb/errors.pyi new file mode 100644 index 000000000000..46b1f5aee972 --- /dev/null +++ b/third_party/3/maxminddb/errors.pyi @@ -0,0 +1,3 @@ +# Stubs for maxminddb.errors (Python 3) + +class InvalidDatabaseError(RuntimeError): ... diff --git a/third_party/3/maxminddb/extension.pyi b/third_party/3/maxminddb/extension.pyi new file mode 100644 index 000000000000..f9261d703665 --- /dev/null +++ b/third_party/3/maxminddb/extension.pyi @@ -0,0 +1,26 @@ +# Stubs for maxminddb.extension (Python 3) + +from typing import Any, Mapping, Sequence + +class InvalidDatabaseError(RuntimeError): ... + +class Reader: + closed: bool = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def close(self, *args: Any, **kwargs: Any) -> Any: ... + def get(self, *args: Any, **kwargs: Any) -> Any: ... + def metadata(self, *args: Any, **kwargs: Any) -> Any: ... + def __enter__(self, *args: Any, **kwargs: Any) -> Any: ... + def __exit__(self, *args: Any, **kwargs: Any) -> Any: ... + +class extension: + node_count: int = ... + record_size: int = ... + ip_version: int = ... + database_type: str = ... + languages: Sequence[str] = ... + binary_format_major_version: int = ... + binary_format_minor_version: int = ... + build_epoch: int = ... + description: Mapping[str, str] = ... + def __init__(self, **kwargs: Any) -> None: ... diff --git a/third_party/3/maxminddb/reader.pyi b/third_party/3/maxminddb/reader.pyi new file mode 100644 index 000000000000..0695a2a0b8f1 --- /dev/null +++ b/third_party/3/maxminddb/reader.pyi @@ -0,0 +1,32 @@ +# Stubs for maxminddb.reader (Python 3) + +from ipaddress import IPv4Address, IPv6Address + +from types import TracebackType +from typing import Any, Mapping, Optional, Sequence, Type, Union + +class Reader: + closed: bool = ... + def __init__(self, database: bytes, mode: int = ...) -> None: ... + def metadata(self) -> 'Metadata': ... + def get(self, ip_address: Union[IPv4Address, IPv6Address]) -> Any: ... + def close(self) -> None: ... + def __enter__(self) -> 'Reader': ... + def __exit__(self, exc_type: Optional[Type[BaseException]] = None, exc_val: Optional[BaseException] = None, exc_tb: Optional[TracebackType] = None) -> None: ... + +class Metadata: + node_count: int = ... + record_size: int = ... + ip_version: int = ... + database_type: str = ... + languages: Sequence[str] = ... + binary_format_major_version: int = ... + binary_format_minor_version: int = ... + build_epoch: int = ... + description: Mapping[str, str] = ... + def __init__(self, **kwargs: Any) -> None: ... + @property + def node_byte_size(self) -> int: ... + @property + def search_tree_size(self) -> int: ... + def __repr__(self) -> str: ... From edf4dde3a613c0b4a680343849c6230efef97d4b Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 19 Sep 2019 17:16:27 +0300 Subject: [PATCH 10/16] Fixed stubs for maxminddb --- third_party/3/maxminddb/reader.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/3/maxminddb/reader.pyi b/third_party/3/maxminddb/reader.pyi index 0695a2a0b8f1..cea5d3798ecf 100644 --- a/third_party/3/maxminddb/reader.pyi +++ b/third_party/3/maxminddb/reader.pyi @@ -12,7 +12,7 @@ class Reader: def get(self, ip_address: Union[IPv4Address, IPv6Address]) -> Any: ... def close(self) -> None: ... def __enter__(self) -> 'Reader': ... - def __exit__(self, exc_type: Optional[Type[BaseException]] = None, exc_val: Optional[BaseException] = None, exc_tb: Optional[TracebackType] = None) -> None: ... + def __exit__(self, exc_type: Optional[Type[BaseException]] = ..., exc_val: Optional[BaseException] = None, exc_tb: Optional[TracebackType] = ...) -> None: ... class Metadata: node_count: int = ... From e3e3f4e9120bebafa26dee5b6767407fc42e7512 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 19 Sep 2019 17:17:39 +0300 Subject: [PATCH 11/16] Fixes stubs for maxminddb --- third_party/3/maxminddb/reader.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/3/maxminddb/reader.pyi b/third_party/3/maxminddb/reader.pyi index cea5d3798ecf..bf150d19b2bd 100644 --- a/third_party/3/maxminddb/reader.pyi +++ b/third_party/3/maxminddb/reader.pyi @@ -12,7 +12,7 @@ class Reader: def get(self, ip_address: Union[IPv4Address, IPv6Address]) -> Any: ... def close(self) -> None: ... def __enter__(self) -> 'Reader': ... - def __exit__(self, exc_type: Optional[Type[BaseException]] = ..., exc_val: Optional[BaseException] = None, exc_tb: Optional[TracebackType] = ...) -> None: ... + def __exit__(self, exc_type: Optional[Type[BaseException]] = ..., exc_val: Optional[BaseException] = ..., exc_tb: Optional[TracebackType] = ...) -> None: ... class Metadata: node_count: int = ... From bf03a3fde145888a7db8ba0f7d3ab71db79ebed8 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 19 Sep 2019 17:34:42 +0300 Subject: [PATCH 12/16] Fixed stubs for maxminddb --- third_party/3/maxminddb/reader.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/3/maxminddb/reader.pyi b/third_party/3/maxminddb/reader.pyi index bf150d19b2bd..fbb1231bbbdd 100644 --- a/third_party/3/maxminddb/reader.pyi +++ b/third_party/3/maxminddb/reader.pyi @@ -8,10 +8,10 @@ from typing import Any, Mapping, Optional, Sequence, Type, Union class Reader: closed: bool = ... def __init__(self, database: bytes, mode: int = ...) -> None: ... - def metadata(self) -> 'Metadata': ... + def metadata(self) -> Metadata: ... def get(self, ip_address: Union[IPv4Address, IPv6Address]) -> Any: ... def close(self) -> None: ... - def __enter__(self) -> 'Reader': ... + def __enter__(self) -> Reader: ... def __exit__(self, exc_type: Optional[Type[BaseException]] = ..., exc_val: Optional[BaseException] = ..., exc_tb: Optional[TracebackType] = ...) -> None: ... class Metadata: From 5dfb0340a23052f070cedc4cd20fae4afef0e954 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 19 Sep 2019 17:52:00 +0300 Subject: [PATCH 13/16] Update third_party/3/maxminddb/extension.pyi Co-Authored-By: Sebastian Rittau --- third_party/3/maxminddb/extension.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/3/maxminddb/extension.pyi b/third_party/3/maxminddb/extension.pyi index f9261d703665..e61a92e3c7ff 100644 --- a/third_party/3/maxminddb/extension.pyi +++ b/third_party/3/maxminddb/extension.pyi @@ -2,7 +2,7 @@ from typing import Any, Mapping, Sequence -class InvalidDatabaseError(RuntimeError): ... +from maxminddb.errors import InvalidDatabaseError as InvalidDatabaseError class Reader: closed: bool = ... From dfdb48fac4c2b5d68c99e773398d1ce17fa3bd38 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 19 Sep 2019 18:07:17 +0300 Subject: [PATCH 14/16] Fixed according to suggestions from @srittau --- third_party/3/maxminddb/compat.pyi | 4 ++-- third_party/3/maxminddb/const.pyi | 11 +++++----- third_party/3/maxminddb/extension.pyi | 29 ++++++++++++++++++--------- third_party/3/maxminddb/reader.pyi | 3 +-- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/third_party/3/maxminddb/compat.pyi b/third_party/3/maxminddb/compat.pyi index 11ac8750afc5..236b0797ea94 100644 --- a/third_party/3/maxminddb/compat.pyi +++ b/third_party/3/maxminddb/compat.pyi @@ -2,9 +2,9 @@ from ipaddress import IPv4Address, IPv6Address -from typing import Any, Union +from typing import Any -def compat_ip_address(address: Any) -> Union[IPv4Address, IPv6Address]: ... +def compat_ip_address(address: object) -> Any: ... def int_from_byte(x: int) -> int: ... def int_from_bytes(x: bytes) -> int: ... def byte_from_int(x: int) -> bytes: ... diff --git a/third_party/3/maxminddb/const.pyi b/third_party/3/maxminddb/const.pyi index e5f8af28616e..36d11a7fa55f 100644 --- a/third_party/3/maxminddb/const.pyi +++ b/third_party/3/maxminddb/const.pyi @@ -1,7 +1,8 @@ # Stubs for maxminddb.const (Python 3) -MODE_AUTO: int -MODE_MMAP_EXT: int -MODE_MMAP: int -MODE_FILE: int -MODE_MEMORY: int +MODE_AUTO: int = ... +MODE_MMAP_EXT: int = ... +MODE_MMAP: int = ... +MODE_FILE: int = ... +MODE_MEMORY: int = ... +MODE_FD: int = ... diff --git a/third_party/3/maxminddb/extension.pyi b/third_party/3/maxminddb/extension.pyi index f9261d703665..24fb851803f3 100644 --- a/third_party/3/maxminddb/extension.pyi +++ b/third_party/3/maxminddb/extension.pyi @@ -2,7 +2,7 @@ from typing import Any, Mapping, Sequence -class InvalidDatabaseError(RuntimeError): ... +from maxminddb.errors import InvalidDatabaseError as InvalidDatabaseError class Reader: closed: bool = ... @@ -14,13 +14,22 @@ class Reader: def __exit__(self, *args: Any, **kwargs: Any) -> Any: ... class extension: - node_count: int = ... - record_size: int = ... - ip_version: int = ... - database_type: str = ... - languages: Sequence[str] = ... - binary_format_major_version: int = ... - binary_format_minor_version: int = ... - build_epoch: int = ... - description: Mapping[str, str] = ... + @property + def node_count(self) -> int: ... + @property + def record_size(self) -> int: ... + @property + def ip_version(self) -> int: ... + @property + def database_type(self) -> str: ... + @property + def languages(self) -> Sequence[str]: ... + @property + def binary_format_major_version(self) -> int: ... + @property + def binary_format_minor_version(self) -> int: ... + @property + def build_epoch(self) -> int: ... + @property + def description(self) -> Mapping[str, str]: ... def __init__(self, **kwargs: Any) -> None: ... diff --git a/third_party/3/maxminddb/reader.pyi b/third_party/3/maxminddb/reader.pyi index fbb1231bbbdd..4a963a65c8ec 100644 --- a/third_party/3/maxminddb/reader.pyi +++ b/third_party/3/maxminddb/reader.pyi @@ -9,7 +9,7 @@ class Reader: closed: bool = ... def __init__(self, database: bytes, mode: int = ...) -> None: ... def metadata(self) -> Metadata: ... - def get(self, ip_address: Union[IPv4Address, IPv6Address]) -> Any: ... + def get(self, ip_address: str) -> Optional[Any]: ... def close(self) -> None: ... def __enter__(self) -> Reader: ... def __exit__(self, exc_type: Optional[Type[BaseException]] = ..., exc_val: Optional[BaseException] = ..., exc_tb: Optional[TracebackType] = ...) -> None: ... @@ -29,4 +29,3 @@ class Metadata: def node_byte_size(self) -> int: ... @property def search_tree_size(self) -> int: ... - def __repr__(self) -> str: ... From f87389f9e0d64bed6b2a64e10d34e0a0216547a3 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 30 Sep 2019 17:19:32 +0300 Subject: [PATCH 15/16] Added ConfigParser.BOOLEAN_STATES # Undocumented --- stdlib/3/configparser.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/3/configparser.pyi b/stdlib/3/configparser.pyi index 17501c1e9e6c..edd68174a1ff 100644 --- a/stdlib/3/configparser.pyi +++ b/stdlib/3/configparser.pyi @@ -4,7 +4,7 @@ import sys from typing import (AbstractSet, MutableMapping, Mapping, Dict, Sequence, List, Union, Iterable, Iterator, Callable, Any, IO, overload, - Optional, Pattern, Type, TypeVar) + Optional, Pattern, Type, TypeVar, ClassVar) # Types only used in type comments only from typing import Optional, Tuple # noqa @@ -57,6 +57,7 @@ class LegacyInterpolation(Interpolation): ... class RawConfigParser(_parser): + BOOLEAN_STATES: ClassVar[Mapping[str, bool]] = ... # Undocumented def __init__(self, defaults: Optional[_section] = ..., dict_type: Type[Mapping[str, str]] = ..., From 203bbc02cdb3a24a704a66260ec046c1eb8daf9f Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 30 Sep 2019 17:24:57 +0300 Subject: [PATCH 16/16] Whitespace fixed for flake8 --- stdlib/3/configparser.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/configparser.pyi b/stdlib/3/configparser.pyi index edd68174a1ff..3f59b611b865 100644 --- a/stdlib/3/configparser.pyi +++ b/stdlib/3/configparser.pyi @@ -57,7 +57,7 @@ class LegacyInterpolation(Interpolation): ... class RawConfigParser(_parser): - BOOLEAN_STATES: ClassVar[Mapping[str, bool]] = ... # Undocumented + BOOLEAN_STATES: ClassVar[Mapping[str, bool]] = ... # Undocumented def __init__(self, defaults: Optional[_section] = ..., dict_type: Type[Mapping[str, str]] = ...,