summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurits van Rees <maurits@vanrees.org>2021-09-02 10:50:47 +0200
committerMaurits van Rees <maurits@vanrees.org>2021-09-02 13:02:38 +0200
commita4052e1fce73d8b099d3b5386109023ecdbdadc8 (patch)
treebac4303b73e4f21ccc1c1789836641965bdde62e
parent583cde4a37e6d76f11b767dea8c518433748ec17 (diff)
downloadzope-i18n-a4052e1fce73d8b099d3b5386109023ecdbdadc8.tar.gz
Manually fix other lint errors.
-rw-r--r--src/zope/i18n/__init__.py4
-rw-r--r--src/zope/i18n/compile.py11
-rw-r--r--src/zope/i18n/format.py2
-rw-r--r--src/zope/i18n/interfaces/__init__.py9
-rw-r--r--src/zope/i18n/locales/__init__.py4
-rw-r--r--src/zope/i18n/locales/tests/test_xmlfactory.py29
-rw-r--r--src/zope/i18n/locales/xmlfactory.py6
-rw-r--r--src/zope/i18n/negotiator.py4
-rw-r--r--src/zope/i18n/testmessagecatalog.py2
-rw-r--r--src/zope/i18n/tests/test_zcml.py3
10 files changed, 45 insertions, 29 deletions
diff --git a/src/zope/i18n/__init__.py b/src/zope/i18n/__init__.py
index f7b582c..45a47e3 100644
--- a/src/zope/i18n/__init__.py
+++ b/src/zope/i18n/__init__.py
@@ -16,7 +16,9 @@
import re
from zope.component import queryUtility
-from zope.i18nmessageid import MessageFactory, Message
+from zope.i18nmessageid import Message
+# I expect that MessageFactory might be there for BBB reasons, but not sure.
+from zope.i18nmessageid import MessageFactory # noqa
from zope.i18n.config import ALLOWED_LANGUAGES
from zope.i18n.interfaces import INegotiator
diff --git a/src/zope/i18n/compile.py b/src/zope/i18n/compile.py
index 30f794e..0d4056c 100644
--- a/src/zope/i18n/compile.py
+++ b/src/zope/i18n/compile.py
@@ -35,11 +35,12 @@ def compile_mo_file(domain, lc_messages_path):
if po_mtime > mo_mtime:
try:
- # Msgfmt.getAsFile returns io.BytesIO on Python 3, and cStringIO.StringIO
- # on Python 2; sadly StringIO isn't a proper context manager, so we have to
- # wrap it with `closing`. Also, Msgfmt doesn't properly close a file
- # it opens for reading if you pass the path, but it does if you pass
- # the file.
+ # Msgfmt.getAsFile returns io.BytesIO on Python 3,
+ # and cStringIO.StringIO on Python 2;
+ # sadly StringIO isn't a proper context manager, so we have to
+ # wrap it with `closing`. Also, Msgfmt doesn't properly close a
+ # file it opens for reading if you pass the path,
+ # but it does if you pass the file.
with open(pofile, 'rb') as pofd:
with closing(Msgfmt(pofd, domain).getAsFile()) as mo:
with open(mofile, 'wb') as fd:
diff --git a/src/zope/i18n/format.py b/src/zope/i18n/format.py
index 43c19c9..2e32da2 100644
--- a/src/zope/i18n/format.py
+++ b/src/zope/i18n/format.py
@@ -456,7 +456,7 @@ class NumberFormat(object):
str(len(res) + 1), exp_bin_pattern
)
exponent = self.symbols['minusSign'] + exponent
- number = obj_int_frac[1][len(res) :]
+ number = obj_int_frac[1][len(res):]
else:
# We have exactly 0
exponent = self._format_integer('0', exp_bin_pattern)
diff --git a/src/zope/i18n/interfaces/__init__.py b/src/zope/i18n/interfaces/__init__.py
index 3231605..b687e67 100644
--- a/src/zope/i18n/interfaces/__init__.py
+++ b/src/zope/i18n/interfaces/__init__.py
@@ -304,7 +304,8 @@ class INegotiator(Interface):
class IUserPreferredCharsets(Interface):
- """This interface provides charset negotiation based on user preferences."""
+ """This interface provides charset negotiation based on user preferences.
+ """
def getPreferredCharsets():
"""Return a sequence of user preferred charsets. Note that the order
@@ -380,9 +381,9 @@ class INumberFormat(IFormat):
\u00A4 This is the currency sign. it will be replaced by a currency
symbol. If it is present in a pattern, the monetary decimal
separator is used instead of the decimal separator.
- \u00A4\u00A4 This is the international currency sign. It will be replaced
- by an international currency symbol. If it is present in a
- pattern, the monetary decimal separator is used instead of
+ \u00A4\u00A4 This is the international currency sign. It will be
+ replaced by an international currency symbol. If it is present
+ in a pattern, the monetary decimal separator is used instead of
the decimal separator.
X Any other characters can be used in the prefix or suffix
' Used to quote special characters in a prefix or suffix
diff --git a/src/zope/i18n/locales/__init__.py b/src/zope/i18n/locales/__init__.py
index 27de94c..989fdff 100644
--- a/src/zope/i18n/locales/__init__.py
+++ b/src/zope/i18n/locales/__init__.py
@@ -33,7 +33,9 @@ from zope.i18n.locales.inheritance import (
InheritingDictionary,
NoParentException,
)
-from zope.i18n.locales.provider import LocaleProvider, LoadLocaleError
+# LoadLocaleError is not used, but might be imported from here by others.
+from zope.i18n.locales.provider import LoadLocaleError # noqa
+from zope.i18n.locales.provider import LocaleProvider
# Setup the locale directory
diff --git a/src/zope/i18n/locales/tests/test_xmlfactory.py b/src/zope/i18n/locales/tests/test_xmlfactory.py
index b1c09bd..2ed49eb 100644
--- a/src/zope/i18n/locales/tests/test_xmlfactory.py
+++ b/src/zope/i18n/locales/tests/test_xmlfactory.py
@@ -34,19 +34,26 @@ class LocaleXMLFileTestCase(TestCase):
# XXX: The tests below are commented out because it's not
# necessary for the xml files to have all format definitions.
- ## Making sure all number format patterns parse
- # for category in (u'decimal', u'scientific', u'percent', u'currency'):
- # for length in getattr(locale.numbers, category+'Formats').values():
- # for format in length.formats.values():
- # self.assert_(parseNumberPattern(format.pattern) is not None)
+ # # Making sure all number format patterns parse
+ # for category in (u"decimal", u"scientific", u"percent", u"currency"):
+ # for length in getattr(
+ # locale.numbers, category + "Formats"
+ # ).values():
+ # for format in length.formats.values():
+ # self.assert_(
+ # parseNumberPattern(format.pattern) is not None
+ # )
- ## Making sure all datetime patterns parse
+ # # Making sure all datetime patterns parse
# for calendar in locale.dates.calendars.values():
- # for category in ('date', 'time', 'dateTime'):
- # for length in getattr(calendar, category+'Formats').values():
- # for format in length.formats.values():
- # self.assert_(
- # parseDateTimePattern(format.pattern) is not None)
+ # for category in ("date", "time", "dateTime"):
+ # for length in getattr(
+ # calendar, category + "Formats"
+ # ).values():
+ # for format in length.formats.values():
+ # self.assert_(
+ # parseDateTimePattern(format.pattern) is not None
+ # )
def test_suite():
diff --git a/src/zope/i18n/locales/xmlfactory.py b/src/zope/i18n/locales/xmlfactory.py
index 244d17e..bfbd593 100644
--- a/src/zope/i18n/locales/xmlfactory.py
+++ b/src/zope/i18n/locales/xmlfactory.py
@@ -347,7 +347,8 @@ class LocaleFactory(object):
>>> names[7:]
[u'August', u'September', u'Oktober', u'November', u'Dezember']
- >>> abbrs = [ctx.months[u"abbreviated"][type] for type in range(1,13)]
+ >>> abbrs = [ctx.months[u"abbreviated"][type]
+ ... for type in range(1,13)]
>>> abbrs[:6]
[u'Jan', u'Feb', u'Mrz', u'Apr', u'Mai', u'Jun']
>>> abbrs[6:]
@@ -1344,7 +1345,8 @@ class LocaleFactory(object):
>>> xml = u'''
... <ldml>
... <layout>
- ... <orientation lines="bottom-to-top" characters="right-to-left" />
+ ... <orientation lines="bottom-to-top"
+ ... characters="right-to-left" />
... </layout>
... </ldml>'''
>>> dom = parseString(xml)
diff --git a/src/zope/i18n/negotiator.py b/src/zope/i18n/negotiator.py
index 8fa0609..ce6ba94 100644
--- a/src/zope/i18n/negotiator.py
+++ b/src/zope/i18n/negotiator.py
@@ -29,8 +29,8 @@ def normalize_langs(langs):
# Make a mapping from normalized->original so we keep can match
# the normalized lang and return the original string.
n_langs = {}
- for l in langs:
- n_langs[normalize_lang(l)] = l
+ for lang in langs:
+ n_langs[normalize_lang(lang)] = lang
return n_langs
diff --git a/src/zope/i18n/testmessagecatalog.py b/src/zope/i18n/testmessagecatalog.py
index a06b15a..b88b3d7 100644
--- a/src/zope/i18n/testmessagecatalog.py
+++ b/src/zope/i18n/testmessagecatalog.py
@@ -29,7 +29,7 @@ class TestMessageCatalog(object):
def queryMessage(self, msgid, default=None):
default = getattr(msgid, 'default', default)
- if default != None and default != msgid:
+ if default is not None and default != msgid:
msg = u"%s (%s)" % (msgid, default)
else:
msg = msgid
diff --git a/src/zope/i18n/tests/test_zcml.py b/src/zope/i18n/tests/test_zcml.py
index 89bff33..b1daf68 100644
--- a/src/zope/i18n/tests/test_zcml.py
+++ b/src/zope/i18n/tests/test_zcml.py
@@ -196,7 +196,8 @@ class DirectivesTest(PlacelessSetup, unittest.TestCase):
template
% '''
<configure package="zope.i18n.tests">
- <i18n:registerTranslations directory="locale3" domain="zope-i18n" />
+ <i18n:registerTranslations directory="locale3"
+ domain="zope-i18n" />
</configure>
''',
self.context,