Skip to content

Commit b5f4941

Browse files
authored
feat: add is_multicast to the list of cached properties (#3)
1 parent ffb7526 commit b5f4941

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/cached_ipaddress/ipaddress.py

+10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ def is_loopback(self) -> bool: # type: ignore[override]
3232
"""Return True if this is a loopback address."""
3333
return super().is_loopback
3434

35+
@cached_property
36+
def is_multicast(self) -> bool: # type: ignore[override]
37+
"""Return True if this is a multicast address."""
38+
return super().is_multicast
39+
3540

3641
class CachedIPv6Address(IPv6Address):
3742
def __str__(self) -> str:
@@ -58,6 +63,11 @@ def is_loopback(self) -> bool: # type: ignore[override]
5863
"""Return True if this is a loopback address."""
5964
return super().is_loopback
6065

66+
@cached_property
67+
def is_multicast(self) -> bool: # type: ignore[override]
68+
"""Return True if this is a multicast address."""
69+
return super().is_multicast
70+
6171

6272
@lru_cache(maxsize=512)
6373
def _cached_ip_addresses(

tests/test_ipaddress.py

+2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ def test_cached_ip_addresses_wrapper():
3030
assert ipv4.is_link_local is False
3131
assert ipv4.is_unspecified is True
3232
assert ipv4.is_loopback is False
33+
assert ipv4.is_multicast is False
3334

3435
ipv6 = ipaddress.cached_ip_addresses("fe80::1")
3536
assert ipv6 is not None
3637
assert ipv6.is_link_local is True
3738
assert ipv6.is_unspecified is False
3839
assert ipv6.is_loopback is False
40+
assert ipv6.is_multicast is False
3941

4042
ipv6 = ipaddress.cached_ip_addresses("0:0:0:0:0:0:0:0")
4143
assert ipv6 is not None

0 commit comments

Comments
 (0)