Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

false positive: E201: invalid variables: %28e #78

Closed
willkg opened this issue Oct 27, 2015 · 3 comments
Closed

false positive: E201: invalid variables: %28e #78

willkg opened this issue Oct 27, 2015 · 3 comments

Comments

@willkg
Copy link
Member

willkg commented Oct 27, 2015

dennis version 0.7
>>> Working on: /Users/rob/git/kuma/locale/it/LC_MESSAGES/django.po
E201: invalid variables: %28e
1029:#: kuma/demos/__init__.py:237
1030:msgid "http://en.wikipedia.org/wiki/Canvas_element"
1031:msgstr "http://it.wikipedia.org/wiki/Canvas_%28elemento_HTML%29"

That's wrong. For python-format, if there are no vars in the msgid, then we don't care about the msgstr.

@willkg willkg closed this as completed in aca57f6 Oct 27, 2015
@robhudson
Copy link
Member

I see you fixed it, but what about something like which I could see easily happening as an extension of this case:

msgid = "Go to this %(adjective)s URL: http://en.wikipedia.org/wiki/Canvas_element"
msgstr = "Go to this %(adjective)s URL: http://it.wikipedia.org/wiki/Canvas_%28elemento_HTML%29"

@willkg
Copy link
Member Author

willkg commented Oct 27, 2015

That'll raise an error:

Python 2.7.10 (default, Sep 24 2015, 17:50:09) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> foo = "Go to this %(adjective)s URL: http://it.wikipedia.org/wiki/Canvas_%%28elemento_HTML%%29" % {'adjective': 'foo'}
>>> foo = "Go to this %(adjective)s URL: http://it.wikipedia.org/wiki/Canvas_%28elemento_HTML%29" % {'adjective': 'foo'}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: not enough arguments for format string
>>> 

They need to double the percent:

msgstr: "Go to this %(adjective)s URL: http://it.wikipedia.org/wiki/Canvas_%%28elemento_HTML%%29"

@robhudson
Copy link
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants