From 4d662f0f49f8429ea1367344c90a16e9514d9704 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 19 Sep 2019 18:49:38 +0300 Subject: [PATCH] Stubs for maxminddb added (#3245) --- third_party/3/maxminddb/__init__.pyi | 9 +++++++ third_party/3/maxminddb/compat.pyi | 10 ++++++++ third_party/3/maxminddb/const.pyi | 8 ++++++ third_party/3/maxminddb/decoder.pyi | 7 ++++++ third_party/3/maxminddb/errors.pyi | 3 +++ third_party/3/maxminddb/extension.pyi | 35 +++++++++++++++++++++++++++ third_party/3/maxminddb/reader.pyi | 31 ++++++++++++++++++++++++ 7 files changed, 103 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 000000000..040872fed --- /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 000000000..236b0797e --- /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 + +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 new file mode 100644 index 000000000..36d11a7fa --- /dev/null +++ b/third_party/3/maxminddb/const.pyi @@ -0,0 +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_FD: int = ... diff --git a/third_party/3/maxminddb/decoder.pyi b/third_party/3/maxminddb/decoder.pyi new file mode 100644 index 000000000..1b7aa6e15 --- /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 000000000..46b1f5aee --- /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 000000000..24fb85180 --- /dev/null +++ b/third_party/3/maxminddb/extension.pyi @@ -0,0 +1,35 @@ +# Stubs for maxminddb.extension (Python 3) + +from typing import Any, Mapping, Sequence + +from maxminddb.errors import InvalidDatabaseError as InvalidDatabaseError + +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: + @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 new file mode 100644 index 000000000..4a963a65c --- /dev/null +++ b/third_party/3/maxminddb/reader.pyi @@ -0,0 +1,31 @@ +# 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: 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: ... + +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: ...