Skip to content

Commit 4c780e7

Browse files
committed
Fix bad i18n and fstrings interaction with flake8
Running 'tox -e pep8' on the neutron tree is showing two identical warnings: NameError: name 'network_id' is not defined These are coming from the metadata and OVN metadata code that is trying to use both the i18n _() along with f-strings. Just change to use %s since this causes a flake8 failure. TrivialFix Change-Id: I8cc903bea1f6202749ee54dee3ee7c6450f324f1 (cherry picked from commit dae69e4)
1 parent d9269bc commit 4c780e7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

neutron/agent/metadata/agent.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,15 @@ def handle(self):
172172
network_id, router_id = self._get_instance_id(req)
173173
if network_id and router_id:
174174
title = '400 Bad Request'
175-
msg = _(f'Both network {network_id} and router {router_id} '
176-
f'defined.')
175+
msg = _('Both network %s and router %s '
176+
'defined.') % (network_id, router_id)
177177
elif network_id:
178178
title = '404 Not Found'
179-
msg = _(f'Instance was not found on network {network_id}.')
179+
msg = _('Instance was not found on network %s.') % network_id
180180
LOG.warning(msg)
181181
else:
182182
title = '404 Not Found'
183-
msg = _(f'Instance was not found on router {router_id}.')
183+
msg = _('Instance was not found on router %s.') % router_id
184184
LOG.warning(msg)
185185
res = common_metadata.encode_http_reponse(title, title, msg)
186186
self.wfile.write(res)

neutron/agent/ovn/metadata/server_socket.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ def handle(self):
148148
network_id, router_id = self._get_instance_id(req)
149149
if network_id and router_id:
150150
title = '400 Bad Request'
151-
msg = _(f'Both network {network_id} and router {router_id} '
152-
f'defined.')
151+
msg = _('Both network %s and router %s '
152+
'defined.') % (network_id, router_id)
153153
elif network_id:
154154
title = '404 Not Found'
155-
msg = _(f'Instance was not found on network {network_id}.')
155+
msg = _('Instance was not found on network %s.') % network_id
156156
LOG.warning(msg)
157157
else:
158158
title = '404 Not Found'
159-
msg = _(f'Instance was not found on router {router_id}.')
159+
msg = _('Instance was not found on router %s.') % router_id
160160
LOG.warning(msg)
161161
res = common_metadata.encode_http_reponse(title, title, msg)
162162
self.wfile.write(res)

0 commit comments

Comments
 (0)