Skip to content

Commit 27e1980

Browse files
committed
chore(tests): remove legacy code <py39
1 parent bd84538 commit 27e1980

4 files changed

Lines changed: 7 additions & 18 deletions

File tree

src/zeroconf/_services/info.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@
7777
_TYPE_TXT,
7878
)
7979

80-
IPADDRESS_SUPPORTS_SCOPE_ID = sys.version_info >= (3, 9, 0)
81-
8280
_IPVersion_All_value = IPVersion.All.value
8381
_IPVersion_V4Only_value = IPVersion.V4Only.value
8482
# https://datatracker.ietf.org/doc/html/rfc6762#section-5.2
@@ -250,7 +248,7 @@ def addresses(self, value: List[bytes]) -> None:
250248
self._get_address_and_nsec_records_cache = None
251249

252250
for address in value:
253-
if IPADDRESS_SUPPORTS_SCOPE_ID and len(address) == 16 and self.interface_index is not None:
251+
if len(address) == 16 and self.interface_index is not None:
254252
addr = ip_bytes_and_scope_to_address(address, self.interface_index)
255253
else:
256254
addr = cached_ip_addresses(address)

src/zeroconf/_utils/ipaddress.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535

3636
bytes_ = bytes
3737
int_ = int
38-
IPADDRESS_SUPPORTS_SCOPE_ID = sys.version_info >= (3, 9, 0)
39-
4038

4139
class ZeroconfIPv4Address(IPv4Address):
4240
__slots__ = ("__hash__", "_is_link_local", "_is_loopback", "_is_unspecified", "_str", "zc_integer")
@@ -128,7 +126,7 @@ def get_ip_address_object_from_record(
128126
record: DNSAddress,
129127
) -> Optional[Union[ZeroconfIPv4Address, ZeroconfIPv6Address]]:
130128
"""Get the IP address object from the record."""
131-
if IPADDRESS_SUPPORTS_SCOPE_ID and record.type == _TYPE_AAAA and record.scope_id:
129+
if record.type == _TYPE_AAAA and record.scope_id:
132130
return ip_bytes_and_scope_to_address(record.address, record.scope_id)
133131
return cached_ip_addresses_wrapper(record.address)
134132

@@ -146,7 +144,7 @@ def ip_bytes_and_scope_to_address(
146144

147145
def str_without_scope_id(addr: Union[ZeroconfIPv4Address, ZeroconfIPv6Address]) -> str:
148146
"""Return the string representation of the address without the scope id."""
149-
if IPADDRESS_SUPPORTS_SCOPE_ID and addr.version == 6:
147+
if addr.version == 6:
150148
address_str = str(addr)
151149
return address_str.partition("%")[0]
152150
return str(addr)

tests/services/test_info.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,6 @@ def test_multiple_addresses():
704704
assert info.addresses == [address, address]
705705
assert info.parsed_addresses() == [address_parsed, address_parsed]
706706
assert info.parsed_scoped_addresses() == [address_parsed, address_parsed]
707-
ipaddress_supports_scope_id = sys.version_info >= (3, 9, 0)
708707

709708
if has_working_ipv6() and not os.environ.get("SKIP_IPV6"):
710709
address_v6_parsed = "2001:db8::1"
@@ -751,9 +750,7 @@ def test_multiple_addresses():
751750
assert info.ip_addresses_by_version(r.IPVersion.All) == [
752751
ip_address(address),
753752
ip_address(address_v6),
754-
ip_address(address_v6_ll_scoped_parsed)
755-
if ipaddress_supports_scope_id
756-
else ip_address(address_v6_ll),
753+
ip_address(address_v6_ll_scoped_parsed),
757754
]
758755
assert info.addresses_by_version(r.IPVersion.V4Only) == [address]
759756
assert info.ip_addresses_by_version(r.IPVersion.V4Only) == [ip_address(address)]
@@ -763,9 +760,7 @@ def test_multiple_addresses():
763760
]
764761
assert info.ip_addresses_by_version(r.IPVersion.V6Only) == [
765762
ip_address(address_v6),
766-
ip_address(address_v6_ll_scoped_parsed)
767-
if ipaddress_supports_scope_id
768-
else ip_address(address_v6_ll),
763+
ip_address(address_v6_ll_scoped_parsed),
769764
]
770765
assert info.parsed_addresses() == [
771766
address_parsed,
@@ -780,16 +775,15 @@ def test_multiple_addresses():
780775
assert info.parsed_scoped_addresses() == [
781776
address_parsed,
782777
address_v6_parsed,
783-
address_v6_ll_scoped_parsed if ipaddress_supports_scope_id else address_v6_ll_parsed,
778+
address_v6_ll_scoped_parsed,
784779
]
785780
assert info.parsed_scoped_addresses(r.IPVersion.V4Only) == [address_parsed]
786781
assert info.parsed_scoped_addresses(r.IPVersion.V6Only) == [
787782
address_v6_parsed,
788-
address_v6_ll_scoped_parsed if ipaddress_supports_scope_id else address_v6_ll_parsed,
783+
address_v6_ll_scoped_parsed,
789784
]
790785

791786

792-
@unittest.skipIf(sys.version_info < (3, 9, 0), "Requires newer python")
793787
def test_scoped_addresses_from_cache():
794788
type_ = "_http._tcp.local."
795789
registration_name = f"scoped.{type_}"

tests/utils/test_ipaddress.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def test_cached_ip_addresses_wrapper():
5252
assert ipv6.is_unspecified is True
5353

5454

55-
@pytest.mark.skipif(sys.version_info < (3, 9, 0), reason="scope_id is not supported")
5655
def test_get_ip_address_object_from_record():
5756
"""Test the get_ip_address_object_from_record."""
5857
# not link local

0 commit comments

Comments
 (0)