Skip to content

Commit 03a04fb

Browse files
committed
Add type hints for Metadata
1 parent a4bdc84 commit 03a04fb

2 files changed

Lines changed: 46 additions & 53 deletions

File tree

HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
History
44
-------
55

6+
2.6.0
7+
++++++++++++++++++
8+
9+
* Added type annotations for instance variables on ``Metadata``
10+
611
2.5.2 (2024-01-09)
712
++++++++++++++++++
813

maxminddb/reader.py

Lines changed: 41 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import struct
1717
from ipaddress import IPv4Address, IPv6Address
1818
from os import PathLike
19-
from typing import Any, AnyStr, IO, Optional, Tuple, Union
19+
from typing import Any, AnyStr, Dict, IO, List, Optional, Tuple, Union
2020

2121
from maxminddb.const import MODE_AUTO, MODE_MMAP, MODE_FILE, MODE_MEMORY, MODE_FD
2222
from maxminddb.decoder import Decoder
@@ -270,67 +270,55 @@ def __enter__(self) -> "Reader":
270270

271271

272272
class Metadata:
273-
"""Metadata for the MaxMind DB reader
273+
"""Metadata for the MaxMind DB reader"""
274274

275+
binary_format_major_version: int
276+
"""
277+
The major version number of the binary format used when creating the
278+
database.
279+
"""
275280

276-
.. attribute:: binary_format_major_version
277-
278-
The major version number of the binary format used when creating the
279-
database.
280-
281-
:type: int
282-
283-
.. attribute:: binary_format_minor_version
284-
285-
The minor version number of the binary format used when creating the
286-
database.
287-
288-
:type: int
289-
290-
.. attribute:: build_epoch
291-
292-
The Unix epoch for the build time of the database.
293-
294-
:type: int
295-
296-
.. attribute:: database_type
297-
298-
A string identifying the database type, e.g., "GeoIP2-City".
299-
300-
:type: str
301-
302-
.. attribute:: description
303-
304-
A map from locales to text descriptions of the database.
305-
306-
:type: dict(str, str)
307-
308-
.. attribute:: ip_version
309-
310-
The IP version of the data in a database. A value of "4" means the
311-
database only supports IPv4. A database with a value of "6" may support
312-
both IPv4 and IPv6 lookups.
313-
314-
:type: int
315-
316-
.. attribute:: languages
317-
318-
A list of locale codes supported by the databse.
319-
320-
:type: list(str)
281+
binary_format_minor_version: int
282+
"""
283+
The minor version number of the binary format used when creating the
284+
database.
285+
"""
321286

322-
.. attribute:: node_count
287+
build_epoch: int
288+
"""
289+
The Unix epoch for the build time of the database.
290+
"""
323291

324-
The number of nodes in the database.
292+
database_type: str
293+
"""
294+
A string identifying the database type, e.g., "GeoIP2-City".
295+
"""
325296

326-
:type: int
297+
description: Dict[str, str]
298+
"""
299+
A map from locales to text descriptions of the database.
300+
"""
327301

328-
.. attribute:: record_size
302+
ip_version: int
303+
"""
304+
The IP version of the data in a database. A value of "4" means the
305+
database only supports IPv4. A database with a value of "6" may support
306+
both IPv4 and IPv6 lookups.
307+
"""
329308

330-
The bit size of a record in the search tree.
309+
languages: List[str]
310+
"""
311+
A list of locale codes supported by the databse.
312+
"""
331313

332-
:type: int
314+
node_count: int
315+
"""
316+
The number of nodes in the database.
317+
"""
333318

319+
record_size: int
320+
"""
321+
The bit size of a record in the search tree.
334322
"""
335323

336324
# pylint: disable=too-many-instance-attributes

0 commit comments

Comments
 (0)