Getting H703 when i am trying i18n _() on running tox -e pep8

Asked by kedar kulkarni

Hi all,

I am trying to edit my plugin to add log message using i18n like this
msg = _("Created a network %s under a tenant %s") % (network_id, tenant_id)

Functionality wise it is fine , but when i run tox -epep8 against this change i am getting H703 multiple positional placeholders.

Why am I getting this error, how to resolve this, Can somebody please help?

Question information

Language:
English Edit question
Status:
Solved
For:
neutron Edit question
Assignee:
No assignee Edit question
Solved by:
ZhiQiang Fan
Solved:
Last query:
Last reply:
Revision history for this message
Best ZhiQiang Fan (aji-zqfan) said :
#1

It means you need to use dictionary-based string formatting (http://www.diveintopython.net/html_processing/dictionary_based_string_formatting.html).

msg = _("Created a network %(net_id)s under a tenant %(tenant_id)s") % {'net_id': network_id, 'tenant_id': tenant_id}

(NOTE this is more than 80 characters in one line, you need to break it down)

Revision history for this message
kedar kulkarni (kedar-kulkarni) said :
#2

Thanks ZhiQiang Fan, that solved my question.