Skip to content

Commit a0d7181

Browse files
committed
remove redundant isinstance()
1 parent b20b15a commit a0d7181

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Lib/ipaddress.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,20 +1017,21 @@ def is_multicast(self):
10171017

10181018
@staticmethod
10191019
def _is_subnet_of(a, b):
1020-
if not isinstance(a, _BaseNetwork):
1021-
raise TypeError(f"{a} is not a network object")
1022-
if not isinstance(b, _BaseNetwork):
1023-
raise TypeError(f"{b} is not a network object")
1020+
# The caller must ensure that 'a' and 'b' are both networks.
10241021
_check_ip_version(a, b)
10251022
return (b.network_address <= a.network_address and
10261023
b.broadcast_address >= a.broadcast_address)
10271024

10281025
def subnet_of(self, other):
10291026
"""Return True if this network is a subnet of other."""
1027+
if not isinstance(other, _BaseNetwork):
1028+
raise TypeError(f"{other} is not a network object")
10301029
return self._is_subnet_of(self, other)
10311030

10321031
def supernet_of(self, other):
10331032
"""Return True if this network is a supernet of other."""
1033+
if not isinstance(other, _BaseNetwork):
1034+
raise TypeError(f"{other} is not a network object")
10341035
return self._is_subnet_of(other, self)
10351036

10361037
@property

0 commit comments

Comments
 (0)