1
0
mirror of https://github.com/django/django.git synced 2025-04-06 22:46:41 +00:00

Removed django.contrib.gis.geoip2.GeoIP2.open() per deprecation timeline.

This commit is contained in:
Sarah Boyce 2024-12-13 09:09:40 +01:00
parent 4104dafdf3
commit 8d695bf510
4 changed files with 2 additions and 31 deletions

View File

@ -14,13 +14,11 @@ directory corresponding to settings.GEOIP_PATH.
import ipaddress
import socket
import warnings
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.validators import validate_ipv46_address
from django.utils._os import to_path
from django.utils.deprecation import RemovedInDjango60Warning
from django.utils.functional import cached_property
__all__ = ["HAS_GEOIP2"]
@ -230,12 +228,3 @@ class GeoIP2:
from django.contrib.gis.geos import Point
return Point(self.lon_lat(query), srid=4326)
@classmethod
def open(cls, full_path, cache):
warnings.warn(
"GeoIP2.open() is deprecated. Use GeoIP2() instead.",
RemovedInDjango60Warning,
stacklevel=2,
)
return GeoIP2(full_path, cache)

View File

@ -99,18 +99,6 @@ Keyword Arguments Description
Methods
=======
Instantiating
-------------
.. classmethod:: GeoIP2.open(path, cache)
This classmethod instantiates the GeoIP object from the given database path
and given cache setting.
.. deprecated:: 5.1
Use the :class:`GeoIP2()` constructor instead.
Querying
--------

View File

@ -307,3 +307,5 @@ to remove usage of these features.
``django.utils.itercompat`` module is removed.
* The ``django.contrib.gis.geoip2.GeoIP2.coords()`` method is removed.
* The ``django.contrib.gis.geoip2.GeoIP2.open()`` method is removed.

View File

@ -7,7 +7,6 @@ from django.conf import settings
from django.contrib.gis.geoip2 import HAS_GEOIP2
from django.contrib.gis.geos import GEOSGeometry
from django.test import SimpleTestCase, override_settings
from django.utils.deprecation import RemovedInDjango60Warning
if HAS_GEOIP2:
import geoip2
@ -201,13 +200,6 @@ class GeoLite2Test(SimpleTestCase):
version = f"{m.binary_format_major_version}.{m.binary_format_minor_version}"
self.assertEqual(repr(g), f"<GeoIP2 [v{version}] _path='{g._path}'>")
def test_open_deprecation_warning(self):
msg = "GeoIP2.open() is deprecated. Use GeoIP2() instead."
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
g = GeoIP2.open(settings.GEOIP_PATH, GeoIP2.MODE_AUTO)
self.assertTrue(g._reader)
self.assertEqual(ctx.filename, __file__)
@skipUnless(HAS_GEOIP2, "GeoIP2 is required.")
@override_settings(