Skip to content

Commit 3348e69

Browse files
committed
Add type stubs for maxminddb.extension
1 parent 6610678 commit 3348e69

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ History
1111
* The ``Metadata`` class object is now available from the C extension
1212
module as ``maxminddb.extension.Metadata`` rather than
1313
``maxminddb.extension.extension``.
14+
* Type stubs have been added for ``maxminddb.extension``.
1415

1516
2.0.3 (2020-10-16)
1617
++++++++++++++++++

maxminddb/extension.pyi

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from ipaddress import IPv4Address, IPv6Address
2+
from os import PathLike
3+
from typing import Any, AnyStr, IO, Mapping, Optional, Sequence, Text, Tuple, Union
4+
5+
from maxminddb import MODE_AUTO
6+
from maxminddb.errors import InvalidDatabaseError as InvalidDatabaseError
7+
from maxminddb.types import Record
8+
9+
class Reader:
10+
closed: bool = ...
11+
def __init__(
12+
self, database: Union[AnyStr, int, PathLike, IO], mode: int = MODE_AUTO
13+
) -> None: ...
14+
def close(self) -> None: ...
15+
def get(
16+
self, ip_address: Union[str, IPv6Address, IPv4Address]
17+
) -> Optional[Record]: ...
18+
def get_with_prefix_len(
19+
self, ip_address: Union[str, IPv6Address, IPv4Address]
20+
) -> Tuple[Optional[Record], int]: ...
21+
def metadata(self) -> "Metadata": ...
22+
def __enter__(self) -> "Reader": ...
23+
def __exit__(self, *args) -> None: ...
24+
25+
class Metadata:
26+
@property
27+
def node_count(self) -> int: ...
28+
@property
29+
def record_size(self) -> int: ...
30+
@property
31+
def ip_version(self) -> int: ...
32+
@property
33+
def database_type(self) -> Text: ...
34+
@property
35+
def languages(self) -> Sequence[Text]: ...
36+
@property
37+
def binary_format_major_version(self) -> int: ...
38+
@property
39+
def binary_format_minor_version(self) -> int: ...
40+
@property
41+
def build_epoch(self) -> int: ...
42+
@property
43+
def description(self) -> Mapping[Text, Text]: ...
44+
def __init__(self, **kwargs: Any) -> None: ...

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def run_setup(with_cext):
107107
long_description=README,
108108
url="http://www.maxmind.com/",
109109
packages=find_packages("."),
110-
package_data={"": ["LICENSE"], "maxminddb": ["py.typed"]},
110+
package_data={"": ["LICENSE"], "maxminddb": ["extension.pyi", "py.typed"]},
111111
package_dir={"maxminddb": "maxminddb"},
112112
python_requires=">=3.6",
113113
include_package_data=True,

0 commit comments

Comments
 (0)