From b5eaa9297d5a5fd6594d64456c081663d7e60165 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 22 Feb 2024 12:55:32 +0800 Subject: [PATCH 01/15] Add leading zeroes tests for inet_pton --- tests/main_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/main_test.py b/tests/main_test.py index c4050f7d..9370ff40 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -156,6 +156,7 @@ def test_lenient_netloc() -> None: def test_looks_like_ip_with_inet_pton() -> None: """Test preferred function to check if a string looks like an IP address.""" assert looks_like_ip("1.1.1.1", inet_pton) is True + assert looks_like_ip("1.1.1.01", inet_pton) is False assert looks_like_ip("a.1.1.1", inet_pton) is False assert looks_like_ip("1.1.1.1\n", inet_pton) is False assert looks_like_ip("256.256.256.256", inet_pton) is False @@ -164,6 +165,7 @@ def test_looks_like_ip_with_inet_pton() -> None: def test_looks_like_ip_without_inet_pton() -> None: """Test fallback function to check if a string looks like an IP address.""" assert looks_like_ip("1.1.1.1", None) is True + assert looks_like_ip("1.1.1.01", None) is False assert looks_like_ip("a.1.1.1", None) is False assert looks_like_ip("1.1.1.1\n", None) is False assert looks_like_ip("256.256.256.256", None) is False From 3998c08bdc597daf1c36d91bad3f41cd654b72ac Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 22 Feb 2024 12:59:06 +0800 Subject: [PATCH 02/15] Format with black --- tests/test_cache.py | 1 + tests/test_trie.py | 1 + tldextract/__main__.py | 1 - tldextract/cache.py | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_cache.py b/tests/test_cache.py index 00bd5a39..756b6939 100644 --- a/tests/test_cache.py +++ b/tests/test_cache.py @@ -1,4 +1,5 @@ """Test the caching functionality.""" + from __future__ import annotations import sys diff --git a/tests/test_trie.py b/tests/test_trie.py index 3c0a1ff0..bfd8e9ad 100644 --- a/tests/test_trie.py +++ b/tests/test_trie.py @@ -1,4 +1,5 @@ """Trie tests.""" + from itertools import permutations from tldextract.tldextract import Trie diff --git a/tldextract/__main__.py b/tldextract/__main__.py index 92e4078e..c187cb86 100644 --- a/tldextract/__main__.py +++ b/tldextract/__main__.py @@ -1,6 +1,5 @@ """tldextract __main__.""" - from .cli import main if __name__ == "__main__": diff --git a/tldextract/cache.py b/tldextract/cache.py index d72eaac0..ce3b1fd6 100644 --- a/tldextract/cache.py +++ b/tldextract/cache.py @@ -1,4 +1,5 @@ """Helpers.""" + from __future__ import annotations import errno From 1844c6dcbdc9a43e8d7f81af115526b9d623fd93 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 22 Feb 2024 13:04:20 +0800 Subject: [PATCH 03/15] Remove inet_pton --- tests/main_test.py | 14 ++------------ tldextract/remote.py | 26 ++------------------------ 2 files changed, 4 insertions(+), 36 deletions(-) diff --git a/tests/main_test.py b/tests/main_test.py index 9370ff40..2266cc67 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -17,7 +17,7 @@ import tldextract import tldextract.suffix_list from tldextract.cache import DiskCache -from tldextract.remote import inet_pton, lenient_netloc, looks_like_ip +from tldextract.remote import lenient_netloc, looks_like_ip from tldextract.suffix_list import SuffixListNotFound from tldextract.tldextract import ExtractResult @@ -152,17 +152,7 @@ def test_lenient_netloc() -> None: ) -@pytest.mark.skipif(not inet_pton, reason="inet_pton unavailable") -def test_looks_like_ip_with_inet_pton() -> None: - """Test preferred function to check if a string looks like an IP address.""" - assert looks_like_ip("1.1.1.1", inet_pton) is True - assert looks_like_ip("1.1.1.01", inet_pton) is False - assert looks_like_ip("a.1.1.1", inet_pton) is False - assert looks_like_ip("1.1.1.1\n", inet_pton) is False - assert looks_like_ip("256.256.256.256", inet_pton) is False - - -def test_looks_like_ip_without_inet_pton() -> None: +def test_looks_like_ip() -> None: """Test fallback function to check if a string looks like an IP address.""" assert looks_like_ip("1.1.1.1", None) is True assert looks_like_ip("1.1.1.01", None) is False diff --git a/tldextract/remote.py b/tldextract/remote.py index 228fa345..35bd519d 100644 --- a/tldextract/remote.py +++ b/tldextract/remote.py @@ -3,15 +3,9 @@ from __future__ import annotations import re -from collections.abc import Callable from ipaddress import AddressValueError, IPv6Address from urllib.parse import scheme_chars -inet_pton: Callable[[int, str], bytes] | None -try: - from socket import AF_INET, AF_INET6, inet_pton # Availability: Unix, Windows. -except ImportError: - inet_pton = None IP_RE = re.compile( r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.)" @@ -59,32 +53,16 @@ def _schemeless_url(url: str) -> str: return url[double_slashes_start + 2 :] -def looks_like_ip( - maybe_ip: str, pton: Callable[[int, str], bytes] | None = inet_pton -) -> bool: +def looks_like_ip(maybe_ip: str) -> bool: """Check whether the given str looks like an IP address.""" if not maybe_ip[0].isdigit(): return False - if pton is not None: - try: - pton(AF_INET, maybe_ip) - return True - except OSError: - return False return IP_RE.fullmatch(maybe_ip) is not None -def looks_like_ipv6( - maybe_ip: str, pton: Callable[[int, str], bytes] | None = inet_pton -) -> bool: +def looks_like_ipv6(maybe_ip: str) -> bool: """Check whether the given str looks like an IPv6 address.""" - if pton is not None: - try: - pton(AF_INET6, maybe_ip) - return True - except OSError: - return False try: IPv6Address(maybe_ip) except AddressValueError: From 26acc45b6ab4d33bbe992fefe5989ae74c118166 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 22 Feb 2024 13:08:08 +0800 Subject: [PATCH 04/15] Try Python 3.8.1 (before leading zero bugfix) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acb4d300..e7f05446 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: os: [macos-latest, windows-latest, ubuntu-latest] language: [ - {python-version: "3.8", toxenv: "py38"}, + {python-version: "3.8.1", toxenv: "py38"}, {python-version: "3.9", toxenv: "py39"}, {python-version: "3.10", toxenv: "py310"}, {python-version: "3.11", toxenv: "py311"}, From 4a7d0b729127cf90b7c50637f8231629362b8ae5 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 22 Feb 2024 13:09:38 +0800 Subject: [PATCH 05/15] Try Python 3.8.7 (before leading zero bugfix) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7f05446..b9ce3972 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: os: [macos-latest, windows-latest, ubuntu-latest] language: [ - {python-version: "3.8.1", toxenv: "py38"}, + {python-version: "3.8.7", toxenv: "py38"}, {python-version: "3.9", toxenv: "py39"}, {python-version: "3.10", toxenv: "py310"}, {python-version: "3.11", toxenv: "py311"}, From 22f2ff749891b611df88b2cd6b2722ab4ce75882 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 22 Feb 2024 13:13:09 +0800 Subject: [PATCH 06/15] Use Ubuntu 20.04 --- .github/workflows/ci.yml | 8 ++++---- tests/main_test.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9ce3972..2344e0c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, windows-latest, ubuntu-latest] + os: [macos-latest, windows-latest, ubuntu-20.04] language: [ {python-version: "3.8.7", toxenv: "py38"}, @@ -16,11 +16,11 @@ jobs: {python-version: "pypy3.8", toxenv: "pypy38"}, ] include: - - os: ubuntu-latest + - os: ubuntu-20.04 language: {python-version: "3.8", toxenv: "codestyle"} - - os: ubuntu-latest + - os: ubuntu-20.04 language: {python-version: "3.8", toxenv: "lint"} - - os: ubuntu-latest + - os: ubuntu-20.04 language: {python-version: "3.8", toxenv: "typecheck"} runs-on: ${{ matrix.os }} steps: diff --git a/tests/main_test.py b/tests/main_test.py index 2266cc67..946e328b 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -154,11 +154,11 @@ def test_lenient_netloc() -> None: def test_looks_like_ip() -> None: """Test fallback function to check if a string looks like an IP address.""" - assert looks_like_ip("1.1.1.1", None) is True - assert looks_like_ip("1.1.1.01", None) is False - assert looks_like_ip("a.1.1.1", None) is False - assert looks_like_ip("1.1.1.1\n", None) is False - assert looks_like_ip("256.256.256.256", None) is False + assert looks_like_ip("1.1.1.1") is True + assert looks_like_ip("1.1.1.01") is False + assert looks_like_ip("a.1.1.1") is False + assert looks_like_ip("1.1.1.1\n") is False + assert looks_like_ip("256.256.256.256") is False def test_similar_to_ip() -> None: From d7001c6a1809b0f1e0834f456a4574ddca0fcf4f Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 22 Feb 2024 13:16:34 +0800 Subject: [PATCH 07/15] Update deprecated linter settings --- pyproject.toml | 6 +++--- tldextract/cache.py | 6 ++---- tldextract/remote.py | 1 - tldextract/tldextract.py | 15 +++++---------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 07dcd9da..d7557cc1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,7 +85,7 @@ strict = true addopts = "--doctest-modules" [tool.ruff] -select = [ +lint.select = [ "A", "B", "C", @@ -97,9 +97,9 @@ select = [ "UP", "W", ] -ignore = [ +lint.ignore = [ "E501", # line too long; if Black does its job, not worried about the rare long line ] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "pep257" diff --git a/tldextract/cache.py b/tldextract/cache.py index ce3b1fd6..7f6d5d01 100644 --- a/tldextract/cache.py +++ b/tldextract/cache.py @@ -38,8 +38,7 @@ def md5(*args: bytes) -> hashlib._Hash: def get_pkg_unique_identifier() -> str: - """ - Generate an identifier unique to the python version, tldextract version, and python instance. + """Generate an identifier unique to the python version, tldextract version, and python instance. This will prevent interference between virtualenvs and issues that might arise when installing a new version of tldextract @@ -66,8 +65,7 @@ def get_pkg_unique_identifier() -> str: def get_cache_dir() -> str: - """ - Get a cache dir that we have permission to write to. + """Get a cache dir that we have permission to write to. Try to follow the XDG standard, but if that doesn't work fallback to the package directory http://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html diff --git a/tldextract/remote.py b/tldextract/remote.py index 35bd519d..048471e8 100644 --- a/tldextract/remote.py +++ b/tldextract/remote.py @@ -6,7 +6,6 @@ from ipaddress import AddressValueError, IPv6Address from urllib.parse import scheme_chars - IP_RE = re.compile( r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.)" r"{3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$" diff --git a/tldextract/tldextract.py b/tldextract/tldextract.py index 902cae69..0e570acd 100644 --- a/tldextract/tldextract.py +++ b/tldextract/tldextract.py @@ -75,8 +75,7 @@ class ExtractResult: @property def registered_domain(self) -> str: - """ - Joins the domain and suffix fields with a dot, if they're both set. + """Joins the domain and suffix fields with a dot, if they're both set. >>> extract('http://forums.bbc.co.uk').registered_domain 'bbc.co.uk' @@ -89,8 +88,7 @@ def registered_domain(self) -> str: @property def fqdn(self) -> str: - """ - Returns a Fully Qualified Domain Name, if there is a proper domain/suffix. + """Returns a Fully Qualified Domain Name, if there is a proper domain/suffix. >>> extract('http://forums.bbc.co.uk/path/to/file').fqdn 'forums.bbc.co.uk' @@ -103,8 +101,7 @@ def fqdn(self) -> str: @property def ipv4(self) -> str: - """ - Returns the ipv4 if that is what the presented domain/url is. + """Returns the ipv4 if that is what the presented domain/url is. >>> extract('http://127.0.0.1/path/to/file').ipv4 '127.0.0.1' @@ -123,8 +120,7 @@ def ipv4(self) -> str: @property def ipv6(self) -> str: - """ - Returns the ipv6 if that is what the presented domain/url is. + """Returns the ipv6 if that is what the presented domain/url is. >>> extract('http://[aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1]/path/to/file').ipv6 'aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1' @@ -334,8 +330,7 @@ def update( @property def tlds(self, session: requests.Session | None = None) -> list[str]: - """ - Returns the list of tld's used by default. + """Returns the list of tld's used by default. This will vary based on `include_psl_private_domains` and `extra_suffixes` """ From cf2b9fd0d3206e460265116475d1e2b6844b8057 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 22 Feb 2024 13:23:45 +0800 Subject: [PATCH 08/15] Revert CI changes --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2344e0c3..acb4d300 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,10 +5,10 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, windows-latest, ubuntu-20.04] + os: [macos-latest, windows-latest, ubuntu-latest] language: [ - {python-version: "3.8.7", toxenv: "py38"}, + {python-version: "3.8", toxenv: "py38"}, {python-version: "3.9", toxenv: "py39"}, {python-version: "3.10", toxenv: "py310"}, {python-version: "3.11", toxenv: "py311"}, @@ -16,11 +16,11 @@ jobs: {python-version: "pypy3.8", toxenv: "pypy38"}, ] include: - - os: ubuntu-20.04 + - os: ubuntu-latest language: {python-version: "3.8", toxenv: "codestyle"} - - os: ubuntu-20.04 + - os: ubuntu-latest language: {python-version: "3.8", toxenv: "lint"} - - os: ubuntu-20.04 + - os: ubuntu-latest language: {python-version: "3.8", toxenv: "typecheck"} runs-on: ${{ matrix.os }} steps: From 10f021c8d47d482429266afae4863f9d7f6db78e Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 22 Feb 2024 13:53:51 +0800 Subject: [PATCH 09/15] Update looks_like_ip docstrings --- tests/main_test.py | 2 +- tldextract/remote.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/main_test.py b/tests/main_test.py index 946e328b..18204033 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -153,7 +153,7 @@ def test_lenient_netloc() -> None: def test_looks_like_ip() -> None: - """Test fallback function to check if a string looks like an IP address.""" + """Test function to check if a string looks like an IPv4 address.""" assert looks_like_ip("1.1.1.1") is True assert looks_like_ip("1.1.1.01") is False assert looks_like_ip("a.1.1.1") is False diff --git a/tldextract/remote.py b/tldextract/remote.py index 048471e8..08b07221 100644 --- a/tldextract/remote.py +++ b/tldextract/remote.py @@ -53,7 +53,7 @@ def _schemeless_url(url: str) -> str: def looks_like_ip(maybe_ip: str) -> bool: - """Check whether the given str looks like an IP address.""" + """Check whether the given str looks like an IPv4 address.""" if not maybe_ip[0].isdigit(): return False From d42beec0de8fdb4238d7e35f5072f562d14a25b2 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 22 Feb 2024 14:02:31 +0800 Subject: [PATCH 10/15] Use old Python 3.8 version --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acb4d300..2344e0c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,10 +5,10 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, windows-latest, ubuntu-latest] + os: [macos-latest, windows-latest, ubuntu-20.04] language: [ - {python-version: "3.8", toxenv: "py38"}, + {python-version: "3.8.7", toxenv: "py38"}, {python-version: "3.9", toxenv: "py39"}, {python-version: "3.10", toxenv: "py310"}, {python-version: "3.11", toxenv: "py311"}, @@ -16,11 +16,11 @@ jobs: {python-version: "pypy3.8", toxenv: "pypy38"}, ] include: - - os: ubuntu-latest + - os: ubuntu-20.04 language: {python-version: "3.8", toxenv: "codestyle"} - - os: ubuntu-latest + - os: ubuntu-20.04 language: {python-version: "3.8", toxenv: "lint"} - - os: ubuntu-latest + - os: ubuntu-20.04 language: {python-version: "3.8", toxenv: "typecheck"} runs-on: ${{ matrix.os }} steps: From a23d29a763b3047f6e6cb0285f506ffb41945886 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 22 Feb 2024 14:08:32 +0800 Subject: [PATCH 11/15] Add test_looks_like_ipv6 --- tests/main_test.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/main_test.py b/tests/main_test.py index 18204033..a537502a 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -17,7 +17,7 @@ import tldextract import tldextract.suffix_list from tldextract.cache import DiskCache -from tldextract.remote import lenient_netloc, looks_like_ip +from tldextract.remote import lenient_netloc, looks_like_ip, looks_like_ipv6 from tldextract.suffix_list import SuffixListNotFound from tldextract.tldextract import ExtractResult @@ -161,6 +161,16 @@ def test_looks_like_ip() -> None: assert looks_like_ip("256.256.256.256") is False +def test_looks_like_ipv6() -> None: + """Test function to check if a string looks like an IPv6 address.""" + assert looks_like_ipv6("::") is True + assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:aaaa:2288") is True + assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1") is True + assert looks_like_ipv6("ZBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1") is False + assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.01") is False + assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:") is False + + def test_similar_to_ip() -> None: """Test strings that look like IP addresses but are not.""" assert_extract("1\xe9", ("", "", "1\xe9", "")) From 2c158cacea96c4e53e0d2ee70e3b5519fc30f60d Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Wed, 28 Feb 2024 13:57:40 +0800 Subject: [PATCH 12/15] Revert to ubuntu-latest. --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20111c35..aa25c115 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,10 +5,10 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, windows-latest, ubuntu-20.04] + os: [macos-latest, windows-latest, ubuntu-latest] language: [ - {python-version: "3.8.7", toxenv: "py38"}, + {python-version: "3.8", toxenv: "py38"}, {python-version: "3.9", toxenv: "py39"}, {python-version: "3.10", toxenv: "py310"}, {python-version: "3.11", toxenv: "py311"}, @@ -18,11 +18,11 @@ jobs: {python-version: "pypy3.10", toxenv: "pypy310"}, ] include: - - os: ubuntu-20.04 + - os: ubuntu-latest language: {python-version: "3.8", toxenv: "codestyle"} - - os: ubuntu-20.04 + - os: ubuntu-latest language: {python-version: "3.8", toxenv: "lint"} - - os: ubuntu-20.04 + - os: ubuntu-latest language: {python-version: "3.8", toxenv: "typecheck"} runs-on: ${{ matrix.os }} steps: From bf5c2766c56c65c24cef4f62d3a48b24f8d36a8d Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Wed, 28 Feb 2024 14:06:11 +0800 Subject: [PATCH 13/15] Use latest Python version for CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa25c115..7d61095e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.language.python-version }} + check-latest: true - name: Install Python requirements run: | pip install --upgrade pip From 6f534f69db2c047c317619cc361cfe1e235a394a Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Thu, 29 Feb 2024 00:33:29 +0800 Subject: [PATCH 14/15] Skip leading zeroes test for ipv6 addresses in Windows + Python 3.8 --- tests/main_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/main_test.py b/tests/main_test.py index a537502a..2229f050 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -4,6 +4,7 @@ import logging import os +import platform import tempfile from collections.abc import Sequence from pathlib import Path @@ -167,7 +168,10 @@ def test_looks_like_ipv6() -> None: assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:aaaa:2288") is True assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1") is True assert looks_like_ipv6("ZBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1") is False - assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.01") is False + if not ( + platform.system() == "Windows" and platform.python_version().startswith("3.8") + ): + assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.01") is False assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:") is False From cfb708f559023e92f002536e6679f0d78cc49f12 Mon Sep 17 00:00:00 2001 From: John Kurkowski Date: Wed, 28 Feb 2024 13:45:13 -0500 Subject: [PATCH 15/15] Try to simplify --- tests/main_test.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/main_test.py b/tests/main_test.py index 2229f050..4b260b14 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -4,7 +4,7 @@ import logging import os -import platform +import sys import tempfile from collections.abc import Sequence from pathlib import Path @@ -168,9 +168,7 @@ def test_looks_like_ipv6() -> None: assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:aaaa:2288") is True assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1") is True assert looks_like_ipv6("ZBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1") is False - if not ( - platform.system() == "Windows" and platform.python_version().startswith("3.8") - ): + if sys.version_info >= (3, 8, 12): # noqa: UP036 assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.01") is False assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:") is False