diff --git a/src/validators/_extremes.py b/src/validators/_extremes.py index fda93f9..3f11ec8 100644 --- a/src/validators/_extremes.py +++ b/src/validators/_extremes.py @@ -23,7 +23,7 @@ class AbsMax: def __ge__(self, other: Any): """GreaterThanOrEqual.""" - return other is not AbsMax + return not isinstance(other, AbsMax) @total_ordering @@ -44,4 +44,4 @@ class AbsMin: def __le__(self, other: Any): """LessThanOrEqual.""" - return other is not AbsMin + return not isinstance(other, AbsMin) diff --git a/src/validators/ip_address.py b/src/validators/ip_address.py index 94a42c6..c7233ee 100644 --- a/src/validators/ip_address.py +++ b/src/validators/ip_address.py @@ -88,7 +88,9 @@ def ipv4( if cidr: if strict and value.count("/") != 1: raise ValueError("IPv4 address was expected in CIDR notation") - return IPv4Network(value, strict=not host_bit) and _check_private_ip(value, private) + # Extract IP part for private check when using CIDR notation + ip_part = value.split('/')[0] if '/' in value else value + return IPv4Network(value, strict=not host_bit) and _check_private_ip(ip_part, private) return IPv4Address(value) and _check_private_ip(value, private) except (ValueError, AddressValueError, NetmaskValueError): return False