From 0f57fb3e02626c87c7cc37ceb5689f73fa07d93e Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Tue, 11 Jun 2024 15:05:03 +0100 Subject: [PATCH] Fix tests broken by new netaddr version netaddr 1.0.0 disabled its INET_ATON flag by default, breaking some of our tests. Re-enable the flag so the tests pass again. --- .cookiecutter/includes/setuptools/install_requires | 2 +- setup.cfg | 2 +- src/checkmatelib/url/canonicalize.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.cookiecutter/includes/setuptools/install_requires b/.cookiecutter/includes/setuptools/install_requires index 5390785..10b9214 100644 --- a/.cookiecutter/includes/setuptools/install_requires +++ b/.cookiecutter/includes/setuptools/install_requires @@ -1,4 +1,4 @@ requests jsonschema importlib_resources -netaddr +netaddr>1.0.0 diff --git a/setup.cfg b/setup.cfg index 7975421..d38b36c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,7 +21,7 @@ install_requires = requests jsonschema importlib_resources - netaddr + netaddr>1.0.0 [options.packages.find] where = src diff --git a/src/checkmatelib/url/canonicalize.py b/src/checkmatelib/url/canonicalize.py index b1c4bcb..796f05f 100644 --- a/src/checkmatelib/url/canonicalize.py +++ b/src/checkmatelib/url/canonicalize.py @@ -7,7 +7,7 @@ import re from urllib.parse import ParseResult, unquote, urlparse -from netaddr import AddrFormatError, IPAddress +from netaddr import INET_ATON, AddrFormatError, IPAddress from checkmatelib.exceptions import BadURL @@ -180,7 +180,7 @@ def _canonicalize_path(cls, path): def _decode_ip(cls, hostname): """Try and spot hostnames that are really encoded IP addresses.""" try: - return str(IPAddress(hostname)) + return str(IPAddress(hostname, flags=INET_ATON)) except (AddrFormatError, ValueError): return None