Skip to content

Commit 7eb83cd

Browse files
chore(pre-commit.ci): auto fixes
1 parent 093fe86 commit 7eb83cd

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/zeroconf/_utils/net.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ def ip6_addresses_to_indexes(
144144
if isinstance(iface, int):
145145
result.append((interface_index_to_ip6_address(adapters, iface), iface))
146146
elif (
147-
isinstance(iface, str) and (ip_address := _cached_ip_addresses(iface)) and ip_address.version == 6
147+
isinstance(iface, str)
148+
and (ip_address := _cached_ip_addresses(iface))
149+
and ip_address.version == 6
148150
):
149151
result.append(ip6_to_address_and_index(adapters, iface))
150152

@@ -172,17 +174,20 @@ def normalize_interface_choice(
172174
result.extend(
173175
ip_tuple
174176
for ip_tuple in get_all_addresses_v6()
175-
if (ip_address := _cached_ip_addresses(ip_tuple[0][0])) and not ip_address.is_loopback
177+
if (ip_address := _cached_ip_addresses(ip_tuple[0][0]))
178+
and not ip_address.is_loopback
176179
)
177180
if ip_version != IPVersion.V6Only:
178181
result.extend(
179182
ip
180183
for ip in get_all_addresses()
181-
if (ip_address := _cached_ip_addresses(ip)) and not ip_address.is_loopback
184+
if (ip_address := _cached_ip_addresses(ip))
185+
and not ip_address.is_loopback
182186
)
183187
if not result:
184188
raise RuntimeError(
185-
'No interfaces to listen on, check that any interfaces have IP version %s' % ip_version
189+
"No interfaces to listen on, check that any interfaces have IP version %s"
190+
% ip_version
186191
)
187192
elif choice is InterfaceChoice.AllWithLoopback:
188193
if ip_version != IPVersion.V4Only:

tests/test_core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ def test_close_multiple_times(self):
9999
@unittest.skipIf(not has_working_ipv6(), "Requires IPv6")
100100
@unittest.skipIf(os.environ.get("SKIP_IPV6"), "IPv6 tests disabled")
101101
def test_launch_and_close_v4_v6(self):
102-
rv = r.Zeroconf(interfaces=r.InterfaceChoice.AllWithLoopback, ip_version=r.IPVersion.All)
102+
rv = r.Zeroconf(
103+
interfaces=r.InterfaceChoice.AllWithLoopback, ip_version=r.IPVersion.All
104+
)
103105
rv.close()
104106
rv = r.Zeroconf(interfaces=r.InterfaceChoice.All, ip_version=r.IPVersion.All)
105107
rv.close()
@@ -111,7 +113,9 @@ def test_launch_and_close_v4_v6(self):
111113
@unittest.skipIf(not has_working_ipv6(), "Requires IPv6")
112114
@unittest.skipIf(os.environ.get("SKIP_IPV6"), "IPv6 tests disabled")
113115
def test_launch_and_close_v6_only(self):
114-
rv = r.Zeroconf(interfaces=r.InterfaceChoice.AllWithLoopback, ip_version=r.IPVersion.V6Only)
116+
rv = r.Zeroconf(
117+
interfaces=r.InterfaceChoice.AllWithLoopback, ip_version=r.IPVersion.V6Only
118+
)
115119
rv.close()
116120
rv = r.Zeroconf(interfaces=r.InterfaceChoice.All, ip_version=r.IPVersion.V6Only)
117121
rv.close()

tests/utils/test_net.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def test_ip6_addresses_to_indexes():
8585
]
8686

8787

88-
@pytest.mark.parametrize("interface_choice", (r.InterfaceChoice.All, r.InterfaceChoice.AllWithLoopback))
88+
@pytest.mark.parametrize(
89+
"interface_choice", (r.InterfaceChoice.All, r.InterfaceChoice.AllWithLoopback)
90+
)
8991
def test_normalize_interface_choice_errors(interface_choice: r.InterfaceChoice) -> None:
9092
"""Test we generate exception on invalid input."""
9193
with patch("zeroconf._utils.net.get_all_addresses", return_value=[]), patch(

0 commit comments

Comments
 (0)