Skip to content

Commit ba22740

Browse files
Add docstrings to IP validation helper functions
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 <noreply@anthropic.com>
1 parent 435e1da commit ba22740

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

httpx/_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ def __eq__(self, other: typing.Any) -> bool:
227227

228228

229229
def is_ipv4_hostname(hostname: str) -> bool:
230+
"""
231+
Check if the given hostname is a valid IPv4 address.
232+
Supports CIDR notation by checking only the address part.
233+
"""
230234
try:
231235
ipaddress.IPv4Address(hostname.split("/")[0])
232236
except Exception:
@@ -235,6 +239,10 @@ def is_ipv4_hostname(hostname: str) -> bool:
235239

236240

237241
def is_ipv6_hostname(hostname: str) -> bool:
242+
"""
243+
Check if the given hostname is a valid IPv6 address.
244+
Supports CIDR notation by checking only the address part.
245+
"""
238246
try:
239247
ipaddress.IPv6Address(hostname.split("/")[0])
240248
except Exception:

0 commit comments

Comments
 (0)