|
5 | 5 |
|
6 | 6 | """ |
7 | 7 | import inspect |
8 | | -from typing import Any, cast, List, Optional, Type, Union |
| 8 | +import os |
| 9 | +from typing import Any, AnyStr, cast, IO, List, Optional, Type, Union |
9 | 10 |
|
10 | 11 | import maxminddb |
11 | 12 |
|
@@ -59,13 +60,16 @@ class Reader: |
59 | 60 | """ |
60 | 61 |
|
61 | 62 | def __init__( |
62 | | - self, fileish: str, locales: Optional[List[str]] = None, mode: int = MODE_AUTO |
| 63 | + self, |
| 64 | + fileish: Union[AnyStr, int, os.PathLike, IO], |
| 65 | + locales: Optional[List[str]] = None, |
| 66 | + mode: int = MODE_AUTO, |
63 | 67 | ) -> None: |
64 | 68 | """Create GeoIP2 Reader. |
65 | 69 |
|
66 | | - :param fileish: The string path to the GeoIP2 database, or an existing |
67 | | - file descriptor pointing to the database. Note that this latter |
68 | | - usage is only valid when mode is MODE_FD. |
| 70 | + :param fileish: A path to the GeoIP2 database or an existing file |
| 71 | + descriptor pointing to the database. Note that a file descriptor |
| 72 | + is only valid when mode is MODE_FD. |
69 | 73 | :param locales: This is list of locale codes. This argument will be |
70 | 74 | passed on to record classes to use when their name properties are |
71 | 75 | called. The default value is ['en']. |
@@ -254,7 +258,9 @@ def _flat_model_for( |
254 | 258 | record["prefix_len"] = prefix_len |
255 | 259 | return model_class(record) |
256 | 260 |
|
257 | | - def metadata(self) -> maxminddb.reader.Metadata: |
| 261 | + def metadata( |
| 262 | + self, |
| 263 | + ) -> Union[maxminddb.reader.Metadata, "maxminddb.extension.Metadata"]: |
258 | 264 | """The metadata for the open database. |
259 | 265 |
|
260 | 266 | :returns: :py:class:`maxminddb.reader.Metadata` object |
|
0 commit comments