From 2d6de8039dcf5d671f5f1ef45c867ba67cbff7c9 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Fri, 24 Sep 2021 10:36:24 -0700 Subject: [PATCH 1/2] Explicitly define public API --- HISTORY.rst | 6 ++++++ geoip2/database.py | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 23e6fd2..40dda13 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,12 @@ History ------- +4.4.0 +++++++++++++++++++ + +* The public API on ``geoip2.database`` is now explicitly defined by + setting ``__all__``. + 4.3.0 (2021-09-20) ++++++++++++++++++ diff --git a/geoip2/database.py b/geoip2/database.py index af50b2a..4074bbd 100644 --- a/geoip2/database.py +++ b/geoip2/database.py @@ -10,8 +10,7 @@ import maxminddb -# pylint: disable=unused-import -from maxminddb import ( # type: ignore +from maxminddb import ( MODE_AUTO, MODE_MMAP, MODE_MMAP_EXT, @@ -35,6 +34,16 @@ ISP, ) +__all__ = [ + "MODE_AUTO", + "MODE_MMAP", + "MODE_MMAP_EXT", + "MODE_FILE", + "MODE_MEMORY", + "MODE_FD", + "Reader", +] + class Reader: """GeoIP2 database Reader object. From dd8df1bc278234e20905576f017ed08a480780d1 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Fri, 24 Sep 2021 10:38:17 -0700 Subject: [PATCH 2/2] Simplify type check --- HISTORY.rst | 2 ++ geoip2/database.py | 2 +- requirements.txt | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 40dda13..c8940f6 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,8 @@ History * The public API on ``geoip2.database`` is now explicitly defined by setting ``__all__``. +* The return type of the ``metadata()`` method on ``Reader`` is now + ``maxminddb.reader.Metadata`` rather than a union type. 4.3.0 (2021-09-20) ++++++++++++++++++ diff --git a/geoip2/database.py b/geoip2/database.py index 4074bbd..6abeafb 100644 --- a/geoip2/database.py +++ b/geoip2/database.py @@ -269,7 +269,7 @@ def _flat_model_for( def metadata( self, - ) -> Union[maxminddb.reader.Metadata, "maxminddb.extension.Metadata"]: + ) -> maxminddb.reader.Metadata: """The metadata for the open database. :returns: :py:class:`maxminddb.reader.Metadata` object diff --git a/requirements.txt b/requirements.txt index ce3f381..239990d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ aiohttp>=3.6.2,<4.0.0 -maxminddb>=2.1.0,<3.0.0 +maxminddb>=2.2.0,<3.0.0 requests>=2.24.0,<3.0.0 urllib3>=1.25.2,<2.0.0