From ba2274031f4fc58cd1a8cb0f6642ab4ac9566ce4 Mon Sep 17 00:00:00 2001 From: Andrey Lebedev Date: Tue, 7 Oct 2025 19:40:01 +0100 Subject: [PATCH] Add docstrings to IP validation helper functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add documentation to is_ipv4_hostname and is_ipv6_hostname functions to clarify their purpose and CIDR notation support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- httpx/_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/httpx/_utils.py b/httpx/_utils.py index 7fe827da4d..1093872dce 100644 --- a/httpx/_utils.py +++ b/httpx/_utils.py @@ -227,6 +227,10 @@ def __eq__(self, other: typing.Any) -> bool: def is_ipv4_hostname(hostname: str) -> bool: + """ + Check if the given hostname is a valid IPv4 address. + Supports CIDR notation by checking only the address part. + """ try: ipaddress.IPv4Address(hostname.split("/")[0]) except Exception: @@ -235,6 +239,10 @@ def is_ipv4_hostname(hostname: str) -> bool: def is_ipv6_hostname(hostname: str) -> bool: + """ + Check if the given hostname is a valid IPv6 address. + Supports CIDR notation by checking only the address part. + """ try: ipaddress.IPv6Address(hostname.split("/")[0]) except Exception: