@@ -6,22 +6,25 @@ This module contains the C extension database reader and related classes.
66
77"""
88
9+ # pylint: disable=E0601,E0602
910from ipaddress import IPv4Address , IPv6Address
1011from os import PathLike
11- from typing import Any , AnyStr , Dict , IO , List , Optional , Tuple , Union
12+ from typing import IO , Any , AnyStr , Optional , Tuple , Union
13+
1214from maxminddb import MODE_AUTO
1315from maxminddb .types import Record
1416
1517class Reader :
16- """
17- A C extension implementation of a reader for the MaxMind DB format. IP
18+ """A C extension implementation of a reader for the MaxMind DB format. IP
1819 addresses can be looked up using the ``get`` method.
1920 """
2021
2122 closed : bool = ...
2223
2324 def __init__ (
24- self , database : Union [AnyStr , int , PathLike , IO ], mode : int = MODE_AUTO
25+ self ,
26+ database : Union [AnyStr , int , PathLike , IO ],
27+ mode : int = MODE_AUTO ,
2528 ) -> None :
2629 """Reader for the MaxMind DB file format
2730
@@ -30,6 +33,7 @@ class Reader:
3033 file, or a file descriptor in the case of MODE_FD.
3134 mode -- mode to open the database with. The only supported modes are
3235 MODE_AUTO and MODE_MMAP_EXT.
36+
3337 """
3438
3539 def close (self ) -> None :
@@ -38,25 +42,26 @@ class Reader:
3842 def get (self , ip_address : Union [str , IPv6Address , IPv4Address ]) -> Optional [Record ]:
3943 """Return the record for the ip_address in the MaxMind DB
4044
41-
4245 Arguments:
4346 ip_address -- an IP address in the standard string notation
47+
4448 """
4549
4650 def get_with_prefix_len (
47- self , ip_address : Union [str , IPv6Address , IPv4Address ]
51+ self ,
52+ ip_address : Union [str , IPv6Address , IPv4Address ],
4853 ) -> Tuple [Optional [Record ], int ]:
4954 """Return a tuple with the record and the associated prefix length
5055
51-
5256 Arguments:
5357 ip_address -- an IP address in the standard string notation
58+
5459 """
5560
56- def metadata (self ) -> " Metadata" :
61+ def metadata (self ) -> Metadata :
5762 """Return the metadata associated with the MaxMind DB file"""
5863
59- def __enter__ (self ) -> " Reader" : ...
64+ def __enter__ (self ) -> Reader : ...
6065 def __exit__ (self , * args ) -> None : ...
6166
6267# pylint: disable=too-few-public-methods
@@ -85,7 +90,7 @@ class Metadata:
8590 A string identifying the database type, e.g., "GeoIP2-City".
8691 """
8792
88- description : Dict [str , str ]
93+ description : dict [str , str ]
8994 """
9095 A map from locales to text descriptions of the database.
9196 """
@@ -97,7 +102,7 @@ class Metadata:
97102 both IPv4 and IPv6 lookups.
98103 """
99104
100- languages : List [str ]
105+ languages : list [str ]
101106 """
102107 A list of locale codes supported by the databse.
103108 """
0 commit comments