From 7cdc4bfa5ef3bd6d06798d9a7a818692c3f0db6a Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 11 Mar 2019 16:41:11 +0300 Subject: [PATCH 01/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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]] = ..., From fcd2edc472214f19573766ca83236cbcfb48da5e Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 30 Sep 2019 18:48:30 +0300 Subject: [PATCH 17/24] Added stub for urllib.request.proxy_bypass() --- stdlib/3/urllib/request.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/3/urllib/request.pyi b/stdlib/3/urllib/request.pyi index b043a115e4ec..63152d445448 100644 --- a/stdlib/3/urllib/request.pyi +++ b/stdlib/3/urllib/request.pyi @@ -34,6 +34,7 @@ def pathname2url(path: str) -> str: ... def getproxies() -> Dict[str, str]: ... def parse_http_list(s: str) -> List[str]: ... def parse_keqv_list(l: List[str]) -> Dict[str, str]: ... +def proxy_bypass(host: str) -> Any: ... # Undocumented class Request: @property From 49449e04e1d91bc7459970b63d40f943bdaafd36 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 30 Sep 2019 18:53:08 +0300 Subject: [PATCH 18/24] Added stub for urllib.request.proxy_bypass() --- stdlib/3/urllib/request.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/3/urllib/request.pyi b/stdlib/3/urllib/request.pyi index b043a115e4ec..63152d445448 100644 --- a/stdlib/3/urllib/request.pyi +++ b/stdlib/3/urllib/request.pyi @@ -34,6 +34,7 @@ def pathname2url(path: str) -> str: ... def getproxies() -> Dict[str, str]: ... def parse_http_list(s: str) -> List[str]: ... def parse_keqv_list(l: List[str]) -> Dict[str, str]: ... +def proxy_bypass(host: str) -> Any: ... # Undocumented class Request: @property From 0dda34c759e10d09667eada57447f33559ddcafd Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 30 Sep 2019 19:06:28 +0300 Subject: [PATCH 19/24] Added stub for asyncore.socket_map, undocumented but useful --- stdlib/2and3/asyncore.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/2and3/asyncore.pyi b/stdlib/2and3/asyncore.pyi index a7fb59c84644..b7ccc9d3cb16 100644 --- a/stdlib/2and3/asyncore.pyi +++ b/stdlib/2and3/asyncore.pyi @@ -15,6 +15,7 @@ from errno import (EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, # cyclic dependence with asynchat _maptype = Dict[str, Any] +socket_map: _maptype = ... # Undocumented class ExitNow(Exception): ... From 8d0732cc979acf024225cd9a20d6458c27457f83 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 30 Sep 2019 19:21:51 +0300 Subject: [PATCH 20/24] Added stub for http.server.BaseHTTPRequestHandler.parse_request(), undocumented but useful. --- stdlib/3/http/server.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/3/http/server.pyi b/stdlib/3/http/server.pyi index dd3118e9fb77..5c624c030465 100644 --- a/stdlib/3/http/server.pyi +++ b/stdlib/3/http/server.pyi @@ -58,6 +58,7 @@ class BaseHTTPRequestHandler: def date_time_string(self, timestamp: Optional[int] = ...) -> str: ... def log_date_time_string(self) -> str: ... def address_string(self) -> str: ... + def parse_request(self) -> bool: ... class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): extensions_map: Dict[str, str] From 047b17dd3d3fcaae82507c3c25e66732f126d5c3 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 30 Sep 2019 20:00:24 +0300 Subject: [PATCH 21/24] Also added stubs for BaseHTTPRequestHandler.weekdayname and monthname --- stdlib/3/http/server.pyi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/3/http/server.pyi b/stdlib/3/http/server.pyi index 5c624c030465..954c076a23d3 100644 --- a/stdlib/3/http/server.pyi +++ b/stdlib/3/http/server.pyi @@ -1,7 +1,7 @@ # Stubs for http.server (Python 3.4) import sys -from typing import Any, BinaryIO, Dict, List, Mapping, Optional, Tuple, Union +from typing import Any, BinaryIO, ClassVar, Dict, List, Mapping, Optional, Sequence, Tuple, Union import socketserver import email.message @@ -36,6 +36,8 @@ class BaseHTTPRequestHandler: protocol_version: str MessageClass: type responses: Mapping[int, Tuple[str, str]] + weekdayname: ClassVar[Sequence[str]] = ... # Undocumented + monthname: ClassVar[Sequence[Optional[str]]] = ... # Undocumented def __init__(self, request: bytes, client_address: Tuple[str, int], server: socketserver.BaseServer) -> None: ... def handle(self) -> None: ... @@ -58,7 +60,7 @@ class BaseHTTPRequestHandler: def date_time_string(self, timestamp: Optional[int] = ...) -> str: ... def log_date_time_string(self) -> str: ... def address_string(self) -> str: ... - def parse_request(self) -> bool: ... + def parse_request(self) -> bool: ... # Undocumented class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): extensions_map: Dict[str, str] From d0df323a27efe02dca9c696040b0778e447b3f94 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Mon, 30 Sep 2019 20:32:18 +0300 Subject: [PATCH 22/24] _maptype seems to be incorrect as the keys seem to be file descriptors; fixed --- stdlib/2and3/asyncore.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/2and3/asyncore.pyi b/stdlib/2and3/asyncore.pyi index b7ccc9d3cb16..9d0a2c60e3f4 100644 --- a/stdlib/2and3/asyncore.pyi +++ b/stdlib/2and3/asyncore.pyi @@ -13,7 +13,7 @@ from errno import (EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, EPIPE, EAGAIN, errorcode) # cyclic dependence with asynchat -_maptype = Dict[str, Any] +_maptype = Dict[int, Any] socket_map: _maptype = ... # Undocumented From f00701f727d25eb8f7e4e82e400a2d4363daf440 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 3 Oct 2019 18:27:58 +0300 Subject: [PATCH 23/24] Added stubs for geoip2 --- third_party/3/geoip2/__init__.pyi | 0 third_party/3/geoip2/database.pyi | 24 +++++++++ third_party/3/geoip2/errors.pyi | 20 +++++++ third_party/3/geoip2/mixins.pyi | 8 +++ third_party/3/geoip2/models.pyi | 68 ++++++++++++++++++++++++ third_party/3/geoip2/records.pyi | 87 +++++++++++++++++++++++++++++++ 6 files changed, 207 insertions(+) create mode 100644 third_party/3/geoip2/__init__.pyi create mode 100644 third_party/3/geoip2/database.pyi create mode 100644 third_party/3/geoip2/errors.pyi create mode 100644 third_party/3/geoip2/mixins.pyi create mode 100644 third_party/3/geoip2/models.pyi create mode 100644 third_party/3/geoip2/records.pyi diff --git a/third_party/3/geoip2/__init__.pyi b/third_party/3/geoip2/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/third_party/3/geoip2/database.pyi b/third_party/3/geoip2/database.pyi new file mode 100644 index 000000000000..00edd588e8b6 --- /dev/null +++ b/third_party/3/geoip2/database.pyi @@ -0,0 +1,24 @@ +# Stubs for geoip2.database (Python 3) + +from types import TracebackType +from typing import Optional, Sequence, Type + +from maxminddb.reader import Metadata +from geoip2.models import AnonymousIP, ASN, City, ConnectionType, Country, Domain, Enterprise, ISP + +_Locales = Optional[Sequence[str]] + +class Reader: + def __init__(self, filename: str, locales: _Locales = ..., mode: int = ...) -> 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 country(self, ip_address: str) -> Country: ... + def city(self, ip_address: str) -> City: ... + def anonymous_ip(self, ip_address: str) -> AnonymousIP: ... + def asn(self, ip_address: str) -> ASN: ... + def connection_type(self, ip_address: str) -> ConnectionType: ... + def domain(self, ip_address: str) -> Domain: ... + def enterprise(self, ip_address: str) -> Enterprise: ... + def isp(self, ip_address: str) -> ISP: ... + def metadata(self) -> Metadata: ... + def close(self) -> None: ... diff --git a/third_party/3/geoip2/errors.pyi b/third_party/3/geoip2/errors.pyi new file mode 100644 index 000000000000..29fcde014f08 --- /dev/null +++ b/third_party/3/geoip2/errors.pyi @@ -0,0 +1,20 @@ +# Stubs for geoip2.errors (Python 3) + +from typing import Optional + +class GeoIP2Error(RuntimeError): ... + +class AddressNotFoundError(GeoIP2Error): ... + +class AuthenticationError(GeoIP2Error): ... + +class HTTPError(GeoIP2Error): + http_status: int = ... + uri: str = ... + def __init__(self, message: str, http_status: Optional[int] = ..., uri: Optional[str] = ...) -> None: ... + +class InvalidRequestError(GeoIP2Error): ... + +class OutOfQueriesError(GeoIP2Error): ... + +class PermissionRequiredError(GeoIP2Error): ... diff --git a/third_party/3/geoip2/mixins.pyi b/third_party/3/geoip2/mixins.pyi new file mode 100644 index 000000000000..fb34a6adf4bb --- /dev/null +++ b/third_party/3/geoip2/mixins.pyi @@ -0,0 +1,8 @@ +# Stubs for geoip2.mixins (Python 3) + +from typing import Any + +class SimpleEquality: + __metaclass__: Any = ... + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... diff --git a/third_party/3/geoip2/models.pyi b/third_party/3/geoip2/models.pyi new file mode 100644 index 000000000000..a29030d375a8 --- /dev/null +++ b/third_party/3/geoip2/models.pyi @@ -0,0 +1,68 @@ +# Stubs for geoip2.models (Python 3) + +from typing import Any, Mapping, Optional, Sequence + +from geoip2 import records + +from geoip2.mixins import SimpleEquality + +_Locales = Optional[Sequence[str]] +_RawResonse = Mapping[str, Mapping[str, Any]] + +class Country(SimpleEquality): + continent: records.Continent = ... + country: records.Country = ... + registered_country: records.Country = ... + represented_country: records.RepresentedCountry = ... + maxmind: records.MaxMind = ... + traits: records.Traits = ... + raw: Any = ... + def __init__(self, raw_response: _RawResonse, locales: _Locales = ...) -> None: ... + +class City(Country): + city: records.City = ... + location: records.Location = ... + postal: records.Postal = ... + subdivisions: records.Subdivisions = ... + def __init__(self, raw_response: _RawResonse, locales: _Locales = ...) -> None: ... + +class Insights(City): ... + +class Enterprise(City): ... + +class SimpleModel(SimpleEquality): + __metaclass__: Any = ... + +class AnonymousIP(SimpleModel): + is_anonymous: bool = ... + is_anonymous_vpn: bool = ... + is_hosting_provider: bool = ... + is_public_proxy: bool = ... + is_tor_exit_node: bool = ... + ip_address: str = ... + raw: str = ... + def __init__(self, raw: str) -> None: ... + +class ASN(SimpleModel): + autonomous_system_number: int = ... + autonomous_system_organization: str = ... + ip_address: str = ... + raw: str = ... + def __init__(self, raw: str) -> None: ... + +class ConnectionType(SimpleModel): + connection_type: str = ... + ip_address: str = ... + raw: str = ... + def __init__(self, raw: str) -> None: ... + +class Domain(SimpleModel): + domain: str = ... + ip_address: str = ... + raw: str = ... + def __init__(self, raw: str) -> None: ... + +class ISP(ASN): + isp: str = ... + organization: str = ... + def __init__(self, raw: str) -> None: ... diff --git a/third_party/3/geoip2/records.pyi b/third_party/3/geoip2/records.pyi new file mode 100644 index 000000000000..893842a96904 --- /dev/null +++ b/third_party/3/geoip2/records.pyi @@ -0,0 +1,87 @@ +# Stubs for geoip2.records (Python 3) + +from typing import Any, Mapping, Optional, Sequence, Tuple + +from geoip2.mixins import SimpleEquality + +_Locales = Optional[Sequence[str]] +_Names = Mapping[str, str] + +class Record(SimpleEquality): + __metaclass__: Any = ... + def __init__(self, **kwargs: Any) -> None: ... + def __setattr__(self, name: str, value: Any) -> None: ... + +class PlaceRecord(Record): + __metaclass__: Any = ... + def __init__(self, locales: _Locales = ..., **kwargs: Any) -> None: ... + @property + def name(self) -> str: ... + +class City(PlaceRecord): + confidence: int = ... + geoname_id: int = ... + names: _Names = ... + +class Continent(PlaceRecord): + code: str = ... + geoname_id: int = ... + names: _Names = ... + +class Country(PlaceRecord): + confidence: int = ... + geoname_id: int = ... + is_in_european_union: bool = ... + iso_code: str = ... + names: _Names = ... + def __init__(self, locales: _Locales = ..., **kwargs: Any) -> None: ... + +class RepresentedCountry(Country): + type: str = ... + +class Location(Record): + average_income: int = ... + accuracy_radius: int = ... + latitude: float = ... + longitude: float = ... + metro_code: int = ... + population_density: int = ... + time_zone: str = ... + +class MaxMind(Record): + queries_remaining: int = ... + +class Postal(Record): + code: str = ... + confidence: int = ... + +class Subdivision(PlaceRecord): + confidence: int = ... + geoname_id: int = ... + iso_code: str = ... + names: _Names = ... + +class Subdivisions(Tuple[Subdivision]): + def __new__(cls, locales: _Locales, *subdivisions: Subdivision) -> Subdivisions: ... + def __init__(self, locales: _Locales, *subdivisions: Subdivision) -> None: ... + @property + def most_specific(self) -> Subdivision: ... + +class Traits(Record): + autonomous_system_number: int = ... + autonomous_system_organization: int = ... + connection_type: str = ... + domain: str = ... + ip_address: str = ... + is_anonymous: bool = ... + is_anonymous_proxy: bool = ... + is_anonymous_vpn: bool = ... + is_hosting_provider: bool = ... + is_legitimate_proxy: bool = ... + is_public_proxy: bool = ... + is_satellite_provider: bool = ... + is_tor_exit_node: bool = ... + isp: str = ... + organization: str = ... + user_type: str = ... + def __init__(self, **kwargs: Any) -> None: ... From e4752a65a0c7db4a129c8c2a9475b2d9b7e24c39 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 3 Oct 2019 18:51:08 +0300 Subject: [PATCH 24/24] Fixed according to flake8 --- third_party/3/geoip2/database.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/3/geoip2/database.pyi b/third_party/3/geoip2/database.pyi index 00edd588e8b6..29071d53a928 100644 --- a/third_party/3/geoip2/database.pyi +++ b/third_party/3/geoip2/database.pyi @@ -11,7 +11,7 @@ _Locales = Optional[Sequence[str]] class Reader: def __init__(self, filename: str, locales: _Locales = ..., mode: int = ...) -> 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] = ..., exc_tb: Optional[TracebackType] = ...) -> None: ... def country(self, ip_address: str) -> Country: ... def city(self, ip_address: str) -> City: ... def anonymous_ip(self, ip_address: str) -> AnonymousIP: ...