Drop compatibility code for Python 3.8

Python 3.8 support has been removed and now the minimum supported
python version is 3.9.

Change-Id: Ic1fa1921ef3c66f5fd32a4e6e23dc843bc877f42
This commit is contained in:
Takashi Kajinami 2024-12-13 23:57:57 +09:00
parent 79f5ec658e
commit bd8d21b353

View File

@ -144,19 +144,10 @@ def get_noscope_ipv6(address):
.. versionadded: 7.3.0:
"""
# TODO(egarciar): Scope was added for IPv6Address on Python 3.9. Same for
# the removesuffix str method. Remove try/except when minimum required
# version for Python is 3.9
try:
_ipv6 = ipaddress.IPv6Address(address)
if _ipv6.scope_id:
address = address.removesuffix('%' + _ipv6.scope_id)
return address
except (ipaddress.AddressValueError, AttributeError):
if is_valid_ipv6(address):
parts = address.rsplit("%", 1)
return parts[0]
raise
_ipv6 = ipaddress.IPv6Address(address)
if _ipv6.scope_id:
address = address.removesuffix('%' + _ipv6.scope_id)
return address
def is_valid_cidr(address):